Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Could not find main class

 
Darcy John
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After compiling my simple little program with no errors when it comes to run it using Java i get the error could not find the main class.

C:\Head First Java\Code\Chapter 1>java Shuffle1.class
Exception in thread "main" java.lang.NoClassDefFoundError: Shuffle1/class
Caused by: java.lang.ClassNotFoundException: Shuffle1.class
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: Shuffle1.class. Program will exit.

this happened with the last little program as well but when I cleared the CLASS PATH it worked fine. This is an annoying little program.



any other information you need feel free to ask

thanks for any help you may be able to provide
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clear the classpath again?

If the class you've written is in the default package, and your classpath is set incorrectly, it's not going to run.

Edit: Wow, I wasn't payng attention. Sorry.
 
Darcy John
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class path at present holds no value.
 
Vijitha Kumara
Bartender
Pie
Posts: 3918
10
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darcy John wrote:The class path at present holds no value.

Since your class in default package if you run from the directory where the class resides use "java -cp . <classname>" command.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way to execute a class is not to use "java Shuffle1.class", but "java Shuffle1".
 
Darcy John
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahh right thanks alot ulf
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic