java interpreter
I am trying to learn Java I downloaded sdk and when i use
java /filename it tells me exeption in thred "main" Java.lang.NoClassdeffounderror Can sombody help me out |
check your classpath and make sure you're leaving the ".class" off of the file when you run it. so, if your file is Hello.class, you'd do:
Code:
java Hello again, assuming your java class file is called Hello.class, run this: Code:
java -cp . Hello if that works, then the problem is with your classpath. oh, and any java class you run directly must have a method with the following signature: Code:
public static void main(String[] args) { <your code here>} |
The hello world program in Java looks like this:
Code:
public class HelloWorld //the name of the main class "must" be the same To run this code you first have to do: javac HelloWorld.java And then you'll get a file called HelloWorld.class, which you may run by writing: java HelloWorld (with no extension!) |
All times are GMT -5. The time now is 08:29 AM. |