This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main"

 
Joanne Ho
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I test my program on NetBeans IDE4.1 by calling "Run"->"Run File"->"Run JEMQInterface.java". It runs perfectly ok.

Since NetBeans will automatically built a jar file for my program at the "./dist" directory under my project directory i.e. "c:\JEMQInterface", I tried to run the jar file without using NetBeans by executing the following at command prompt:
>java JEMQInterface

Then it failed to run and produce the exception.

Could anyone help. Thanks.


Exception in thread "main" java.lang.NoClassDefFoundError: JEMQInterface (wrong
name: JEMQInterface/JEMQInterface)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
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)
[ November 15, 2005: Message edited by: Joanne Ho ]
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To run a jar file, you should type
java -jar JEMQInterface.jar
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exception in thread "main" java.lang.NoClassDefFoundError: JEMQInterface (wrong name: JEMQInterface/JEMQInterface)

There's something wrong with the directory structure in your JAR file. You have a "package JEMQInterface;" statement in your source file, but the class file is in the root inside the JAR file, instead of in a subdirectory JEMQInterface.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic