space Posted January 28, 2006 Share Posted January 28, 2006 Hi, I´m trying to run a Hello World app just to check if the java enviroment is OK. I´m getting an error: $ java HelloWorldApp.java Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp/java I have tried different classpaths and javahomes, and searched google for info but haven´t come any further... What is it supposed to be? Now I have them set like this: $ echo $JAVAHOME /Library/Java/Home/ $ echo $JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/ $ echo $CLASSPATH /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/:/Library/Java/Extensions/:./ Thankful for any hints! Link to comment Share on other sites More sharing options...
sigxcpu Posted January 29, 2006 Share Posted January 29, 2006 $ javac -classpath . HelloWorldApp.java $ java -classpath . HelloWorldApp java is a compiled language, not interpreted. Link to comment Share on other sites More sharing options...
jfn Posted February 7, 2006 Share Posted February 7, 2006 To elaborate: you need to compile the .java file, which produces a new file. You then run that new file. javac is the java compiler, so you use the javac command first, then use java to run your compiled code. This is different from some other languages, which are interpreted (on the fly), like Perl and PHP scripts, Matlab .m files, HTML pages, etc. But for most heavy duty languages (like C and Java), you need to first compile your code, which means it doesn't need to be interpreted from high-level arguments into low-level arguments each time you run it. It's faster that way. Link to comment Share on other sites More sharing options...
Recommended Posts