• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java stopped working

 
sharingan reddy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey guys i did a simple hello world in x.java
^_^ cat x.java

public class x {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("hi vishu");
}

}

^_^ javac x.java
^_^ java x
Exception in thread "main" java.lang.NoClassDefFoundError: x
Caused by: java.lang.ClassNotFoundException: x
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: x. Program will exit.
0_o

you see my java suddenly failed
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to set the classpath properly. Try "java -classpath . x" (note the dot in there, which means "use the current directory as classpath").

In case you're using the CLASSPATH environment variable, I generally advise not to use it; it's more trouble than it's worth.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic