Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Weird message when running class file

 
Logan Knecht
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just installed the SDK and was trying to run a hellworld.class file that was compiled by javac, but when I do java helloworld.class in the correct directory it gives me this.

C:\Documents and Settings\Work\Desktop>java helloworld.class
Exception in thread "main" java.lang.NoClassDefFoundError: helloworld/class
Caused by: java.lang.ClassNotFoundException: helloworld.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)

Does anyone know what the problem is or how to fix it?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Logan,
Welcome to JavaRanch!

The correct command is "java helloworld". The .class is not part of the command.
 
Logan Knecht
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haha oops, thank you very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic