[FIXED] Cannot use JIntellitype with double-clickable jar

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

Re: [NOTFIXED] Cannot use JIntellitype with double-clickable jar

Postby DJGummikuh » Fri Jul 31, 2009 7:39 am

Works like a Charme.
Your code is really MUCH! cleaner... My code was written during my bus trip to work.
I also noticed you removed the dependency on commons-logging. Cool, makes my program a little smaller :)
Thank you very much for your great support for your library
DJGummikuh
 
Posts: 13
Joined: Mon Jul 27, 2009 2:45 am

Re: [FIXED] Cannot use JIntellitype with double-clickable jar

Postby Melloware » Fri Jul 31, 2009 7:45 am

Awesome! Thanks for testing!

Also I fixed your name on the Contributor's page.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11050
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: [FIXED] Cannot use JIntellitype with double-clickable jar

Postby Dark$hadow » Tue Aug 04, 2009 7:10 am

Hi,

Thank you for your tip but the dll still can't be found in my JAR file :(

Here is my main tree :

|_ lib
|_ jintellitype-1.3.2.jar
|_ myJar.jar
|_ JIntellitype.dll

and my Jar tree :
|_ client.logic.myMain.class
|_ JIntellitype.dll

(I've put the dll in both path to have more chances to detect it)

And in my "myMain.class", I try to load locate the dll like this :
Code: Select all
      // Hook to get the correct path to the dll when we use the JAR
      URL dll = getClass().getResource("/JIntellitype.dll");

           JIntellitype.setLibraryLocation(dll.toString());


Could you help me to find the way to make it works?

Thank you very much !!!

PS: Sorry for my English, I'm French...
Dark$hadow
 
Posts: 9
Joined: Tue Aug 04, 2009 7:01 am

Re: [FIXED] Cannot use JIntellitype with double-clickable jar

Postby Melloware » Tue Aug 04, 2009 7:25 am

Can you try using getFile() instead of toString()?

Code: Select all
dll.getFile()


I am not sure if this is going to be possible with the DLL living inside the JAR as I have never tried it but basically since the System.load wants a file path.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11050
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: [FIXED] Cannot use JIntellitype with double-clickable jar

Postby Dark$hadow » Tue Aug 04, 2009 8:05 am

I've tried but it still doesn't works :(

I don't need the dll to be in the JAR. Be in the same folder would be perfect.
Dark$hadow
 
Posts: 9
Joined: Tue Aug 04, 2009 7:01 am

Re: [FIXED] Cannot use JIntellitype with double-clickable jar

Postby Melloware » Tue Aug 04, 2009 8:08 am

Dark$hadow wrote:I've tried but it still doesn't works :(

I don't need the dll to be in the JAR. Be in the same folder would be perfect.


if it is in the same folder as the other code then you should be able to just remove the setLibraryLocation() line. It should just find the Jintellitpye.dll if it is in the same directory as you are executing the code in. If that doesn't work first try hardcoding setLibraryLocation("C:\location\Jintellitype.dll"); just to get past your issues first. Once you have it working then it's just a matter of figuring out how and where to load it in your code.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11050
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: [FIXED] Cannot use JIntellitype with double-clickable jar

Postby Dark$hadow » Tue Aug 04, 2009 8:44 am

Thanks for your help :)

I've tried the first method you propose but I got the same error.

But by hardcoding the fullpath, it succeed !!

So my problem is now to know how to refer to the dll from my main class (which is in the JAR). :?

Any idea?
Dark$hadow
 
Posts: 9
Joined: Tue Aug 04, 2009 7:01 am

Re: [FIXED] Cannot use JIntellitype with double-clickable jar

Postby Melloware » Tue Aug 04, 2009 9:28 am

Dark$hadow wrote:Thanks for your help :)

I've tried the first method you propose but I got the same error.

But by hardcoding the fullpath, it succeed !!

So my problem is now to know how to refer to the dll from my main class (which is in the JAR). :?

Any idea?


What happens in your code if you do...

Code: Select all
File file = new File(".");
System.Out.PrintLn(file.getAbsolutePath());


I am hoping that returns you the directory of where your JAR is so then you could just append "JINtellitype.dll" on the end of it and pass it to SetLibraryLocation().
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11050
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: [FIXED] Cannot use JIntellitype with double-clickable jar

Postby Dark$hadow » Tue Aug 04, 2009 10:25 am

Bad news...

This out in console: "C:\Users\Pierre\."
Dark$hadow
 
Posts: 9
Joined: Tue Aug 04, 2009 7:01 am

Re: [FIXED] Cannot use JIntellitype with double-clickable jar

Postby Melloware » Tue Aug 04, 2009 11:20 am

try this one... where MyClass is your Class.

Code: Select all
File file= new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
System.Out.PrintLn(file.getAbsolutePath());
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11050
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: [FIXED] Cannot use JIntellitype with double-clickable jar

Postby Dark$hadow » Wed Aug 05, 2009 2:22 am

Better news!!!

I get now a full path: "C:\Users\Pierre\Desktop\Client\Click2Dial-Computer\build\install\lib\Clic2Dial.jar"

Does the same function without the file name exists?

Many thanks for your help !!!
Dark$hadow
 
Posts: 9
Joined: Tue Aug 04, 2009 7:01 am

Re: [FIXED] Cannot use JIntellitype with double-clickable jar

Postby Melloware » Wed Aug 05, 2009 6:02 am

Dark$hadow wrote:Better news!!!

I get now a full path: "C:\Users\Pierre\Desktop\Client\Click2Dial-Computer\build\install\lib\Clic2Dial.jar"

Does the same function without the file name exists?

Many thanks for your help !!!


OK now with that File object you can just call file.getParent().getAbsolutePath() since Parent will be the directory path of CLic2Dial.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11050
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: [FIXED] Cannot use JIntellitype with double-clickable jar

Postby Dark$hadow » Wed Aug 05, 2009 6:52 am

Arf nearly !!!

That's the code:
Code: Select all
      File file = null;
      try {
         file = new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
      } catch (URISyntaxException e1) {
         e1.printStackTrace();
      }
      System.out.println(file.getParent().getAbsolutePath());


I can't call the getAbsolutePath() method ("The method getAbsolutePath() is undefined for the type String")

The solution is near :)
Dark$hadow
 
Posts: 9
Joined: Tue Aug 04, 2009 7:01 am

Re: [FIXED] Cannot use JIntellitype with double-clickable jar

Postby Melloware » Wed Aug 05, 2009 8:16 am

Sorry try .getParentFile() or new File(file.getParent()). I know there is a way to get the parent file object.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Melloware Inc.
http://www.melloware.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
User avatar
Melloware
Site Admin
 
Posts: 11050
Joined: Thu Dec 01, 2005 10:24 pm
Location: Philadelphia, Pennsylvania USA

Re: [FIXED] Cannot use JIntellitype with double-clickable jar

Postby Dark$hadow » Wed Aug 05, 2009 8:31 am

Wonderful!!!

The final code is:

Code: Select all
      File file = null;
      try {
         file = new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
         
      } catch (URISyntaxException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
      }

JIntellitype.setLibraryLocation(file.getParentFile().getAbsolutePath() + "\\JIntellitype.dll");


It's very complicated to find a path :?

Many tanks to you !!!
Dark$hadow
 
Posts: 9
Joined: Tue Aug 04, 2009 7:01 am

PreviousNext

Return to JIntellitype

Who is online

Users browsing this forum: No registered users and 1 guest

cron