Results 1 to 7 of 7
- 07-17-2011, 01:08 PM #1
Member
- Join Date
- May 2010
- Posts
- 23
- Rep Power
- 0
Class Not Found Exception when trying to open a .jar file
I've been encountering this exceptions recently. My java program would work just fine if I run it from the IDE or via command line (run the .class file). But when I use the IDE (netbeans) make an executable file (.jar), the program doesn't run at all. It says something like "Class Not Found Exception" or "No Class Definition Found"...
I do not problem lies with my code. It's probably just the java configuration on my PC...
So what should I do to fix this?
Thanks
-
how are you calling the jar, and what packages are present? And can you post the exact error messages?
- 07-17-2011, 02:56 PM #3
Open a command prompt, change to the folder with the jar file and enter:
java -jar <YOURJARFILENAME>.jar
Copy the console window and paste here.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
- 07-22-2011, 09:49 PM #4
Member
- Join Date
- Jul 2011
- Posts
- 2
- Rep Power
- 0
I've seen this a lot in NetBeans. This happens when you move/rename your main class after initial project creation. Even when doing a move or rename through refactoring, NetBeans does not update the main class namespace for the project (which is written to the jar manifest file when building).
To select the new main class, right-click on your project in the projects pane, go to properties. Go to the 'run' category on the left hand side, then click browse next to Main Class. It should only display your main class, unless you have multiple classes in the project with a main() method. Select the proper class, close out of the dialog, and run a clean and build on the project.
Assuming this is the problem, you should be able to run the jar using 'java -jar JarName.jar'
Not enough info given to be sure this is the issue, but like I've said, I've run into this a lot. Hope it helps :)
- 07-23-2011, 11:25 AM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
Does your .jar file even have a manifest entry and is it pointing to the class that contains the static main( ... ) method?
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 07-24-2011, 09:08 AM #6
Member
- Join Date
- May 2011
- Posts
- 35
- Rep Power
- 0
Is that possible you are facing jar hell issue?
If you suspect this, probably you need to use verbose option to verify this.
- 07-25-2011, 10:34 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
Class not found Exception
By surendra in forum Java ServletReplies: 8Last Post: 06-09-2011, 12:52 PM -
File not found exception on ObjectInputStream
By pink123 in forum New To JavaReplies: 8Last Post: 06-08-2011, 04:00 PM -
No Property Editor Found Exception -JSF 1.2
By venkatcanwin in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 11-18-2010, 06:02 AM -
How do I open a file with a class, or can I?
By bobleny in forum New To JavaReplies: 4Last Post: 04-02-2009, 09:59 AM -
class not found exception while using IKVM to create exe for c#
By manjunath k reddy in forum New To JavaReplies: 0Last Post: 02-21-2009, 06:05 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks