class example {
public static void main(string args []) {
Sysytem.out.printIn (This is a simple Java program....);
}
}

I am using Windows Vista Ultimate

I tried to rum this program in DOS shell......
Error 1 :Exception in thread "main" java.land.NoClassDefFoundError : example

I tried to remove it...by
>java -classpath.example
But, still I got an error..
Error 2 :Unrecognized option : -classpath.example
Could not create the Java virtual machine.

I am using jre1.5.0_06 and jdk1.5.0_06

Please help...ASAP
Thanks in advance

What file name did you save as? You must save the file name as exactly the same as your class name 'example.java'.

Line 2, it is 'String', not 'string'.

Line 4, try Sysytem.out.println("This is a simple Java program...."); instead. You are calling a wrong 'printIn' which should be 'println'. Also, the value inside the parenthesis must be a string in your case.

Java is case-sensitive programming language. You must be very careful on it.

PS: jdk1.5 is obsoleted already. You should use 1.6 or higher because it contains many bug fixed packages from 1.5.

Edited 6 Years Ago by Taywin: n/a

class example {

public static void main(String args []) {

System.out.println ("This is a simple Java program....");

}

}

I hope this code is correct.......
But still it is showing the same errors.. !!!!!

dude.. u need to set the classpath
so the following

in command promt .. go to d:\example
write the following without quotes

"set classpath="

@nipponsahore

D:/example>set classpath=

I did this.......

then.....

D:/java -classpath.example

That showed
Unrecognized option : -classpath.example
Could not create the Java virtual machine.

I hope u can help me a bit further.....

public class example {
 
 public static void main(String arg []) {
    
    System.out.printIn("Hello World !!!!!");
   }
}

@packetpirate

I did as u said......
Unrecognized option : -classpath.example
Could not create the Java virtual machine.

I wasn't sure if that would fix the problem or not, but nevertheless, you still need to make it public.

@packetpirate

Well..that's ok.....I have started JAVA today only....That was my first program....That taught me much.....

Tell me onething....Could it be a problem of the version of jdk/jre I am using....
'cause it version 1.5....and I use Windows Vista.......
Do I need to download a new version...????

hey .. just write ..
set classpath =

nothing else
it will set that example directory as your classpath .. u dont ned to write anything else

This article has been dead for over six months. Start a new discussion instead.