Friday, July 31, 2009

Java application not working?

okay, I compiled the java app just like the tutorial on www.sun.java.com says. (The hello world one) now I have in my C:/java folder... HelloWorldApp.jar, HelloWorldApp.myclass and HelloWorldApp.java. But when i go into command and type: 'C:/Java/ java HelloWorldApp' it gives me this error:





Exception in the thread "main" java.lang.NoClassDefFoundError: HelloWorldApp (wrong name: helloworldapp/HelloWorldApp)


at java.lang.ClassLoader.defineClass1(Nativ... Method)


at java.lang.ClassLoader.defineClass1(Unkno... source)....





Then it just gives me a bunch more at java errors....





Whats wrong with it?





Regards, Daniel

Java application not working?
1). Java is case sensitive HelloWorldApp is not helloworldapp





2).Check your Classpath...is your class file located in right folder?





hope this will help


Cheers:)
Reply:This error indicates that the JVM cannot find the class. This could be a spelling error (remember, Java is case sensitive). If you have put the class in a package, then the package path is part of the name.





Also, the JVM needs to be told where to find your class files. You mention HelloWorldApp.jar. You might try





C:/Java/java -classpath HelloWorldApp.jar HelloWorldApp





This assumes that you are running this command in the directory where the jar is sitting.





Good luck!


No comments:

Post a Comment