wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception in thread "main"" Watch "Exception in thread "main"" New topic

Exception in thread "main"

Joanne Ho

Joined: Nov 15, 2005
Posts: 3
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

Joined: Jul 22, 2000
Posts: 9044
To run a jar file, you should type
java -jar JEMQInterface.jar

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14116

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
I agree. Here's the link: http://aspose.com/file-tools
subject: Exception in thread "main"