Jump to content
IGNORED

Java gurus


Guest theSun

Recommended Posts

So I wrote a bunch of code for a Java project, and I can get it to compile with the javac command, but whenever i try to run a script there's a bunch of "can't find class" errors. I'm assuming that this has something to do with my environment variables, but i have appended my java \lib directory in TEMP -> CLASSPATH and the \bin directory in TEMP -> Path. Here's the error. This is probably something really dumb but i can't figure it out :(

 

javaerror.jpg

Link to comment
https://forum.watmm.com/topic/49938-java-gurus/
Share on other sites

You can use the option -classpath instead of environment variables:

 

java -classpath <path of the directory where the class resides you want to run> <name of the class you want to run>

Yo, my name is Saad and I don't give a fuck.

Link to comment
https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147657
Share on other sites

i'm trying

 

java -classpath <C:\Program Files\Java\jdk1.6.0_16\Examples\Example 3> nameofscript.java

 

and it's saying it can't find the file? The example directories are my own, i'm positive that the syntax is as written.

 

sorry to be a bother but i don't want to waste class time with troubleshooting.

Link to comment
https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147692
Share on other sites

yeah, -classpath should solve your problem. however, i strongly recommend, if you haven't yet, check out Eclipse IDE. it will make your life so much easier if you plan on coding any more java.

 

  On 10/19/2009 at 10:12 PM, theSun said:

i'm trying

 

java -classpath <C:\Program Files\Java\jdk1.6.0_16\Examples\Example 3> nameofscript.java

 

and it's saying it can't find the file? The example directories are my own, i'm positive that the syntax is as written.

 

sorry to be a bother but i don't want to waste class time with troubleshooting.

get rid of the "<>" parentheses

Link to comment
https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147694
Share on other sites

yeah, put the file path in double quotes, like this:

 

java -classpath "C:\Program Files\Java\jdk1.6.0_16\Examples\Example 3" nameofscript.java

 

lol, also, you shouldn't be running a .java file, but a compiled, .class file instead!

Link to comment
https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147717
Share on other sites

yeah you are right on the money. as you can see it cannot find "C:\Program Files\Java\jdk1.6.0_16\Examples\Example" not "C:\Program Files\Java\jdk1.6.0_16\Examples\Example 3", cmd.exe cannot read minds you have to pay attention to syntax, especially spaces, because thats one of the first things it looks for when separating arguments.

Link to comment
https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147727
Share on other sites

okay, look. first, you gotta compile the .java (source) file, so you have a .class (binary) file. you do that with javac i presume.

 

then, you want to run your .class file in the java virtual machine. you do that with the "java" command. i think you must not use the ".class" extension though. just the classname. and classes' names should be capitalized.

Link to comment
https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147739
Share on other sites

yeah the javaclasspath system is quite obscure, took me 4 hours to figure out how it works(then i coded in 30 minutes a htmlUnit thingy in order to deconnect/reconnect my internet whereas i did'nt know a single word of javascript.)

 

Sometimes computers are just computers.

 

Anyway, you've just fortgotten to add the current path (.) in your classpath.

i mean the thing you get from running pwd.

 

just try this:

  Quote
java -classpath .;C:\Program Files\Java\jdk1.6.0_16\Examples\Example 3> nameofscript
Edited by Babar
Link to comment
https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147853
Share on other sites

  On 10/19/2009 at 10:38 PM, kokoon said:

then, you want to run your .class file in the java virtual machine. you do that with the "java" command. i think you must not use the ".class" extension though. just the classname. and classes' names should be capitalized.

 

haha! should have paid attention in class. i got my env variable mess worked out after class today, and i can actually start testing my project! hooray!

 

thanks watmm.

 

edit - forgot to submit this before, but i just turned in the whole project. it's fun (lol) coding something without any way of testing, really makes you pay attention to syntax. only a few errors in my project, quickly corrected with watmm's help!

Link to comment
https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147952
Share on other sites

i know what you mean. it really is kind of fun, but if you gotta get some work done, it's so much slower. if you use an IDE like Eclipse, code fies from your mind straight into the source. with all the autocomplete and template and navigation features. and it's so much more difficult to make an e.g. syntax error, because the compiler is checking your source on-the-fly and shows you what's wrong. really, try it!

 

though i do remember coding in notepad.exe or even on paper :) it was fun, but i wouldn't want to do it that way if i wanted to actually make something work.

 

glad you made it work!

Link to comment
https://forum.watmm.com/topic/49938-java-gurus/#findComment-1148151
Share on other sites

programming, especially algorithms is something i never get tired of. and i really got used to java, it's a nice and clean language.

Link to comment
https://forum.watmm.com/topic/49938-java-gurus/#findComment-1148340
Share on other sites

  On 10/20/2009 at 5:10 PM, kokoon said:

java, it's a nice and clean language.

 

:emotawesomepm9:

 

I wouldn't exactly call Java clean.

Yo, my name is Saad and I don't give a fuck.

Link to comment
https://forum.watmm.com/topic/49938-java-gurus/#findComment-1148583
Share on other sites

yeah java does not equal clean. although i don't know what language is. maybe some kind of assembly, or pure C, or even haskell? i guess it depends on how you define clean.

Link to comment
https://forum.watmm.com/topic/49938-java-gurus/#findComment-1148610
Share on other sites

  On 10/20/2009 at 10:32 PM, Bubba69 said:

yeah java does not equal clean. although i don't know what language is. maybe some kind of assembly, or pure C, or even haskell? i guess it depends on how you define clean.

 

Haskell is pretty clean to me, because of its mathematical underpinnings. But if that's of any use in the real world, I wouldn't know, I don't do real world.

Yo, my name is Saad and I don't give a fuck.

Link to comment
https://forum.watmm.com/topic/49938-java-gurus/#findComment-1148656
Share on other sites

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   1 Member

×
×