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

Recommended Answers

All 15 Replies

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.

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.. !!!!!

What is the name of the file you have the class in?

Filename : example
The path of the file.... D:/example/example.java

You might want to make the main class public?

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.....

Have you made the main class public yet?

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

In line 3, you put it wrong... it should be...

public static void main(String[] arg) {

@Taywin

It works either way. Also, it's args, not arg.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.