[SOLVED] Runs in Eclipse but Throws a class not found error

Feature Requests, Comments, Bugs, and Suggestions on the JIntellitype Java API.

[SOLVED] Runs in Eclipse but Throws a class not found error

Postby shane75776 » Thu Apr 26, 2012 7:47 pm

Basically I have absolutely no problems whatsoever running it from eclipse. But when I package everything into a jar, I get this error:
Image

What happens in my jar is it extracts the Jintellitype.dll and loads it and then registers the hotkeys and what not. Again, works perfectly fine in eclipse, but trying from a jar it just crashes the jar with a class
not found error.

Here is a picture of my eclipse project setup with the referenced libraries and jars.
Image

And this is all im doing code wise... If I comment out this section of code, the jar runs fine also.
Code: Select all
JIntellitype.getInstance().registerHotKey(1, JIntellitype.MOD_CONTROL + JIntellitype.MOD_SHIFT, (int)'1');
          JIntellitype.getInstance().registerHotKey(2, JIntellitype.MOD_CONTROL + JIntellitype.MOD_SHIFT, (int)'2');
         JIntellitype.getInstance().addHotKeyListener(new HotkeyListener()
         {
            
            @Override
            public void onHotKey(int identifier)
            {
               if(identifier == 1)
               {
                  initializeOverlay(false, true);
               }
               else if(identifier == 2)
               {
                  initializeOverlay(false, false);
               }
               
            }
         });
shane75776
 
Posts: 3
Joined: Thu Apr 26, 2012 7:40 pm

Re: Runs in Eclipse but Throws a class not found error in Jar

Postby Melloware » Fri Apr 27, 2012 5:30 am

No ClassDefFound is exactly what it says. When you are running outside of Eclipse then the JIntellitype.jar is not found on your classpath. Make sure your JAR references are set up properly on the classpath.

Eclipse takes care of the classpath for you like in that screenshot.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11020
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: Runs in Eclipse but Throws a class not found error in Jar

Postby shane75776 » Fri Apr 27, 2012 11:12 am

My class path should be set up correclt, all the other jars I am referencing work fine, it is only the jintellitype that has this issue. I tried to manually edit my manifest file and it didn't even have a class path entry, so I added it manually , so I did
Class-Path: lib/jintellitype.jar

I even tried /lib/jintellitype.jar and that didn't work either...

Eclipse should be doing this all correctly so I have no idea what's going on...
shane75776
 
Posts: 3
Joined: Thu Apr 26, 2012 7:40 pm

Re: Runs in Eclipse but Throws a class not found error in Jar

Postby shane75776 » Fri Apr 27, 2012 2:38 pm

Figured it out, apparently I needed to package it as a "runnable jar" rather than the regular "jar" option.
shane75776
 
Posts: 3
Joined: Thu Apr 26, 2012 7:40 pm

Re: Runs in Eclipse but Throws a class not found error in Jar

Postby Melloware » Fri Apr 27, 2012 4:21 pm

shane75776 wrote:Figured it out, apparently I needed to package it as a "runnable jar" rather than the regular "jar" option.


Yep!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11020
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA


Return to JIntellitype

Who is online

Users browsing this forum: No registered users and 1 guest