Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #8505 > unrolled thread

loading dll within a jar

Started byPhilipp Kraus <philipp.kraus@flashpixx.de>
First post2011-10-03 22:47 +0200
Last post2011-10-16 22:38 -0400
Articles 8 — 4 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  loading dll within a jar Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-10-03 22:47 +0200
    Re: loading dll within a jar Owen Jacobson <angrybaldguy@gmail.com> - 2011-10-03 23:53 -0400
      Re: loading dll within a jar Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-10-04 11:19 +0200
      Re: loading dll within a jar Roedy Green <see_website@mindprod.com.invalid> - 2011-10-04 02:33 -0700
        Re: loading dll within a jar Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-10-04 14:19 +0200
    Re: loading dll within a jar Roedy Green <see_website@mindprod.com.invalid> - 2011-10-03 22:28 -0700
    Re: loading dll within a jar Roedy Green <see_website@mindprod.com.invalid> - 2011-10-15 14:20 -0700
    Re: loading dll within a jar Arne Vajhøj <arne@vajhoej.dk> - 2011-10-16 22:38 -0400

#8505 — loading dll within a jar

FromPhilipp Kraus <philipp.kraus@flashpixx.de>
Date2011-10-03 22:47 +0200
Subjectloading dll within a jar
Message-ID<j6d70q$24c$1@online.de>
Hello,

is there a way to load a DLL library that is stored within a Jar?
At the time I'm using the -Djava.library.path flag but I would like
to store the DLL within the Jar and added the path dynamically.

I've found some information about this eg extract the DLL to the
temp directory and set the -D option on the main-method.

Can I set also the library path to the java command like the classpath
argument? My java classes use the a
static { System.loadLibrary("dllname"); }
to load the library, so can I add on the static attribute a call for loading
the dll within the jar?

Thanks

Phil

[toc] | [next] | [standalone]


#8507

FromOwen Jacobson <angrybaldguy@gmail.com>
Date2011-10-03 23:53 -0400
Message-ID<201110032353253223-angrybaldguy@gmailcom>
In reply to#8505
On 2011-10-03 20:47:22 +0000, Philipp Kraus said:

> Hello,
> 
> is there a way to load a DLL library that is stored within a Jar?
> At the time I'm using the -Djava.library.path flag but I would like
> to store the DLL within the Jar and added the path dynamically.
> 
> I've found some information about this eg extract the DLL to the
> temp directory and set the -D option on the main-method.
> 
> Can I set also the library path to the java command like the classpath
> argument? My java classes use the a
> static { System.loadLibrary("dllname"); }
> to load the library, so can I add on the static attribute a call for loading
> the dll within the jar?
> 
> Thanks
> 
> Phil

DLL files (and their Unix counterparts) are loaded by the OS's binary 
image loader, which near-universally expects a program or library to 
come from a file on the filesystem. A loader that's clever enough to 
look inside a ZIP file is a rare beast indeed.

Short answer, no, you can't get there from here. Unpack your .DLL 
somewhere (java.io.tmpdir, for example) and load it from there. The 
Java Web Start protocol includes support for native libraries 
distributed inside JAR files, if you don't want to write the 
unpack-and-load glue yourself and if your app is appropriate for web 
start.

-o

[toc] | [prev] | [next] | [standalone]


#8509

FromPhilipp Kraus <philipp.kraus@flashpixx.de>
Date2011-10-04 11:19 +0200
Message-ID<j6ej3v$dlr$1@online.de>
In reply to#8507
On 2011-10-04 05:53:25 +0200, Owen Jacobson said:

> On 2011-10-03 20:47:22 +0000, Philipp Kraus said:
> 
>> Hello,
>> 
>> is there a way to load a DLL library that is stored within a Jar?
>> At the time I'm using the -Djava.library.path flag but I would like
>> to store the DLL within the Jar and added the path dynamically.
>> 
>> I've found some information about this eg extract the DLL to the
>> temp directory and set the -D option on the main-method.
>> 
>> Can I set also the library path to the java command like the classpath
>> argument? My java classes use the a
>> static { System.loadLibrary("dllname"); }
>> to load the library, so can I add on the static attribute a call for loading
>> the dll within the jar?
>> 
>> Thanks
>> 
>> Phil
> 
> DLL files (and their Unix counterparts) are loaded by the OS's binary 
> image loader, which near-universally expects a program or library to 
> come from a file on the filesystem. A loader that's clever enough to 
> look inside a ZIP file is a rare beast indeed.
> 
> Short answer, no, you can't get there from here. Unpack your .DLL 
> somewhere (java.io.tmpdir, for example) and load it from there. The 
> Java Web Start protocol includes support for native libraries 
> distributed inside JAR files, if you don't want to write the 
> unpack-and-load glue yourself and if your app is appropriate for web 
> start.


Thanks for your answers. I will take a look to the Webstart but I think 
I write my own glue code

Phil

[toc] | [prev] | [next] | [standalone]


#8511

FromRoedy Green <see_website@mindprod.com.invalid>
Date2011-10-04 02:33 -0700
Message-ID<nfkl87t2nkv4regjeck6fko9bnp5u7jk4a@4ax.com>
In reply to#8507
On Mon, 3 Oct 2011 23:53:25 -0400, Owen Jacobson
<angrybaldguy@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>Short answer, no, you can't get there from here. Unpack your .DLL 
>somewhere (java.io.tmpdir, for example) and load it from there. The 
>Java Web Start protocol includes support for native libraries 
>distributed inside JAR files, if you don't want to write the 
>unpack-and-load glue yourself and if your app is appropriate for web 
>start.

Doing this with applets is a bear.  A long time ago I went nearly nuts
trying to do it under Netscape and brethren and Java 1.1. The problem
was Java did not notice the DLL unless it were present when Java was
first loaded. You have to find a place to put the DLL on the library
path. You need permission to put it there.

It is easier to let Java Web Start handle this for you.  If you use an
installer, it should have facilities to install the DLL for you.  See
http://mindprod.com/jgloss/installer.html
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
It should not be considered an error when the user starts something
already started or stops something already stopped. This applies
to browsers, services, editors... It is inexcusable to 
punish the user by requiring some elaborate sequence to atone,
e.g. open the task editor, find and kill some processes.

[toc] | [prev] | [next] | [standalone]


#8517

FromPhilipp Kraus <philipp.kraus@flashpixx.de>
Date2011-10-04 14:19 +0200
Message-ID<j6etl4$lda$1@online.de>
In reply to#8511
On 2011-10-04 11:33:11 +0200, Roedy Green said:

> On Mon, 3 Oct 2011 23:53:25 -0400, Owen Jacobson
> <angrybaldguy@gmail.com> wrote, quoted or indirectly quoted someone
> who said :
> 
>> Short answer, no, you can't get there from here. Unpack your .DLL
>> somewhere (java.io.tmpdir, for example) and load it from there. The
>> Java Web Start protocol includes support for native libraries
>> distributed inside JAR files, if you don't want to write the
>> unpack-and-load glue yourself and if your app is appropriate for web
>> start.
> 
> Doing this with applets is a bear.

No it will be a standalone package.

>  A long time ago I went nearly nuts
> trying to do it under Netscape and brethren and Java 1.1. The problem
> was Java did not notice the DLL unless it were present when Java was
> first loaded. You have to find a place to put the DLL on the library
> path. You need permission to put it there.
> 
> It is easier to let Java Web Start handle this for you.  If you use an
> installer, it should have facilities to install the DLL for you.  See
> http://mindprod.com/jgloss/installer.html

At the moment I use a swtich to load the library, the load will be first
from the default system lib path or the user can specify the path

Grat hint, thank

Phil

[toc] | [prev] | [next] | [standalone]


#8508

FromRoedy Green <see_website@mindprod.com.invalid>
Date2011-10-03 22:28 -0700
Message-ID<196l87hsgtbg8tr2a4k8ijp6bfdf5sh4fm@4ax.com>
In reply to#8505
On Mon, 3 Oct 2011 22:47:22 +0200, Philipp Kraus
<philipp.kraus@flashpixx.de> wrote, quoted or indirectly quoted
someone who said :

>is there a way to load a DLL library that is stored within a Jar?

The easiest way is to use Java Web Start.  It will even select the
dll/object code  for the particular platform.
see http://mindprod.com/jgloss/javawebstart.html
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
It should not be considered an error when the user starts something
already started or stops something already stopped. This applies
to browsers, services, editors... It is inexcusable to 
punish the user by requiring some elaborate sequence to atone,
e.g. open the task editor, find and kill some processes.

[toc] | [prev] | [next] | [standalone]


#8833

FromRoedy Green <see_website@mindprod.com.invalid>
Date2011-10-15 14:20 -0700
Message-ID<v7uj97pgbrclvfc8hm39lndt456p65dm4k@4ax.com>
In reply to#8505
On Mon, 3 Oct 2011 22:47:22 +0200, Philipp Kraus
<philipp.kraus@flashpixx.de> wrote, quoted or indirectly quoted
someone who said :

>is there a way to load a DLL library that is stored within a Jar?

see http://mindprod.com/jgloss/javawebstart.html
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
It should not be considered an error when the user starts something
already started or stops something already stopped. This applies
to browsers, services, editors... It is inexcusable to 
punish the user by requiring some elaborate sequence to atone,
e.g. open the task editor, find and kill some processes.

[toc] | [prev] | [next] | [standalone]


#8896

FromArne Vajhøj <arne@vajhoej.dk>
Date2011-10-16 22:38 -0400
Message-ID<4e9b950e$0$294$14726298@news.sunsite.dk>
In reply to#8505
On 10/3/2011 4:47 PM, Philipp Kraus wrote:
> is there a way to load a DLL library that is stored within a Jar?
> At the time I'm using the -Djava.library.path flag but I would like
> to store the DLL within the Jar and added the path dynamically.
>
> I've found some information about this eg extract the DLL to the
> temp directory and set the -D option on the main-method.
>
> Can I set also the library path to the java command like the classpath
> argument? My java classes use the a
> static { System.loadLibrary("dllname"); }
> to load the library, so can I add on the static attribute a call for
> loading
> the dll within the jar?

The right answer is having the DLL external.

Use JWS for SE and JCA for EE to get a little help.

If you really want to mess around then you embed
JLAN in your app, have it serve the jar file as
a windows share and load from that share.

I would not do that.

Arne

PS: JLAN is either GPL or commercial license with the
     implications that carry.


[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web