Guest theSun Posted October 19, 2009 Report Share Posted October 19, 2009 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 :( Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/ Share on other sites More sharing options...
ericsosh Posted October 19, 2009 Report Share Posted October 19, 2009 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> Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Hide ericsosh's signature Hide all signatures 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 More sharing options...
Guest theSun Posted October 19, 2009 Report Share Posted October 19, 2009 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. Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147692 Share on other sites More sharing options...
kokoon Posted October 19, 2009 Report Share Posted October 19, 2009 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 Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147694 Share on other sites More sharing options...
Bubba69 Posted October 19, 2009 Report Share Posted October 19, 2009 im not used the the windows cmd line, but are you allowed to use spaces like that in the path without escaping? Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Hide Bubba69's signature Hide all signatures https://intervallux.bandcamp.com/ Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147704 Share on other sites More sharing options...
Guest theSun Posted October 19, 2009 Report Share Posted October 19, 2009 here's the same error... ???? Wtf am i doing wrong, this is my last college programming class and i can't even get the 2nd assignment to run grrrrrrrrrrrrrrrrrr Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147712 Share on other sites More sharing options...
kokoon Posted October 19, 2009 Report Share Posted October 19, 2009 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! Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147717 Share on other sites More sharing options...
Guest theSun Posted October 19, 2009 Report Share Posted October 19, 2009 still nothing.... same exact error Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147724 Share on other sites More sharing options...
Bubba69 Posted October 19, 2009 Report Share Posted October 19, 2009 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. Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Hide Bubba69's signature Hide all signatures https://intervallux.bandcamp.com/ Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147727 Share on other sites More sharing options...
kokoon Posted October 19, 2009 Report Share Posted October 19, 2009 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. Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147739 Share on other sites More sharing options...
kokoon Posted October 19, 2009 Report Share Posted October 19, 2009 so? did you get it to work? Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147783 Share on other sites More sharing options...
Guest Super lurker ultra V12 Posted October 19, 2009 Report Share Posted October 19, 2009 rm -fr / Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147790 Share on other sites More sharing options...
Guest Babar Posted October 19, 2009 Report Share Posted October 19, 2009 (edited) 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 October 20, 2009 by Babar Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147853 Share on other sites More sharing options...
Guest theSun Posted October 20, 2009 Report Share Posted October 20, 2009 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! Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1147952 Share on other sites More sharing options...
kokoon Posted October 20, 2009 Report Share Posted October 20, 2009 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! Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1148151 Share on other sites More sharing options...
Guest theSun Posted October 20, 2009 Report Share Posted October 20, 2009 i'm going to get eclipse later today. for some reason i thought it wasn't free... i don't really mind coding at the academic level, but i can't imagine writing complex programs (video games, AI, sensory programming, etc), i'd go crazy within a year. Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1148284 Share on other sites More sharing options...
kokoon Posted October 20, 2009 Report Share Posted October 20, 2009 programming, especially algorithms is something i never get tired of. and i really got used to java, it's a nice and clean language. Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1148340 Share on other sites More sharing options...
Guest ezkerraldean Posted October 20, 2009 Report Share Posted October 20, 2009 Javanese gurus are the best in Indonesia. Quote Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1148546 Share on other sites More sharing options...
ericsosh Posted October 20, 2009 Report Share Posted October 20, 2009 On 10/20/2009 at 5:10 PM, kokoon said: java, it's a nice and clean language. I wouldn't exactly call Java clean. Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Hide ericsosh's signature Hide all signatures 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 More sharing options...
Bubba69 Posted October 20, 2009 Report Share Posted October 20, 2009 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. Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Hide Bubba69's signature Hide all signatures https://intervallux.bandcamp.com/ Link to comment https://forum.watmm.com/topic/49938-java-gurus/#findComment-1148610 Share on other sites More sharing options...
ericsosh Posted October 20, 2009 Report Share Posted October 20, 2009 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. Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Hide ericsosh's signature Hide all signatures 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 More sharing options...
Recommended Posts