BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Deploying JAR plus DLL

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder Deployment
View previous topic :: View next topic  
Author Message
Lora Murphy
Guest





PostPosted: Thu Oct 09, 2003 2:59 pm    Post subject: Deploying JAR plus DLL Reply with quote



Hello all,
I have an application that I am currently running from a JAR file, built
with JBuilder 9. It uses JNI to link to a C++ DLL. I package the JAR using
the Archive Builder, setting it to Application. I can take the JAR and DLL
files and put them into a random directory on my machine, and everything
runs great.

I then send the JAR and DLL files to someone else to run, who has only a
Java Virtual Machine installed (i.e., regular Joe User). They put the JAR
and DLL into the same directory on their machine. The Java-only parts of
the JAR run fine, but an UnsatisfiedLinkError is thrown when it comes time
to load the DLL.

It was my understanding that a JAR would be able to find a DLL that was in
its own directory. Is this wrong? And if it is, then I am confused about
library path requirements, and need an explanation of what has to happen on
a user's machine in order to run a JAR that calls a DLL.

Thanks for any help!
--Lora.


Back to top
Lori M Olson (TeamB)
Guest





PostPosted: Thu Oct 09, 2003 7:44 pm    Post subject: Re: Deploying JAR plus DLL Reply with quote



Lora Murphy wrote:
Quote:
Hello all,
I have an application that I am currently running from a JAR file, built
with JBuilder 9. It uses JNI to link to a C++ DLL. I package the JAR using
the Archive Builder, setting it to Application. I can take the JAR and DLL
files and put them into a random directory on my machine, and everything
runs great.

I then send the JAR and DLL files to someone else to run, who has only a
Java Virtual Machine installed (i.e., regular Joe User). They put the JAR
and DLL into the same directory on their machine. The Java-only parts of
the JAR run fine, but an UnsatisfiedLinkError is thrown when it comes time
to load the DLL.

It was my understanding that a JAR would be able to find a DLL that was in
its own directory. Is this wrong? And if it is, then I am confused about
library path requirements, and need an explanation of what has to happen on
a user's machine in order to run a JAR that calls a DLL.

Thanks for any help!
--Lora.



DLL's have to be in the system path to be found this way. You may have
"." (the current directory) in your system path. The people having
problems probably don't have "." in their system path's.

--

Regards,

Lori Olson (TeamB)

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html


Back to top
Valentino Kyriakides
Guest





PostPosted: Thu Oct 09, 2003 9:33 pm    Post subject: Re: Deploying JAR plus DLL Reply with quote



"Lori M Olson (TeamB)" <javadragon (AT) techie (DOT) com> schrieb im Newsbeitrag
news:3f85bab9$1 (AT) newsgroups (DOT) borland.com...
Quote:
...
DLL's have to be in the system path to be found this way. You may have
"." (the current directory) in your system path. The people having
problems probably don't have "." in their system path's.


Yes, even this is maybe the easiest way to get things working, it under
certain circumstances (those Lori mentioned) needs user intervention.

Another possibility is to handle this directly inside the Java dll loading
code for a specific directory and if there the requested dll can't be found,
to fall back to the general dll loading mechanism.

Here is a code fragment which shows what I mean. Note however that in this
example the first place dll loading is JBuilder specific, since it is taken
from one of my personal custom JB OTs. - For a general Java app, that part
would have been to be substituted with some accessing mechanism for the
current directory the Java app resides in:


private void initTrackpointLibrary() throws Exception
{
String rootDir = JBuilder.getRootDir();
String lib = System.mapLibraryName(DLL_NAME);
Url url = PropertyManager.getInstallRootUrl().getRelativeUrl("lib/ext");
// <-- JB OTAPI specific part
File libFile = new File( url.getFileObject(), lib );
if (libFile.exists())
{
trace("loading trackpoint.dll form: " + libFile.getCanonicalPath());
System.load(libFile.getCanonicalPath());
}
else
{
trace("loading trackpoint.dll form java.lib.path");
System.loadLibrary(DLL_NAME);
}

setDebug(conf.debug);
startCaptureTrackpointMessages();
}


-Valentino



Back to top
Osuman B.
Guest





PostPosted: Thu Oct 23, 2003 5:55 am    Post subject: Re: Deploying JAR plus DLL Reply with quote

Always before you deploy programs
Try running it outside the machine you
programmed it.
Test it on other machines before releasing it.

If you are deploying on windows use a good
installer software and let it link the DLL for
you

Osuman

"Valentino Kyriakides" <vkyr (AT) nospam-ision (DOT) net> wrote

Quote:

"Lori M Olson (TeamB)" <javadragon (AT) techie (DOT) com> schrieb im Newsbeitrag
news:3f85bab9$1 (AT) newsgroups (DOT) borland.com...
...
DLL's have to be in the system path to be found this way. You may have
"." (the current directory) in your system path. The people having
problems probably don't have "." in their system path's.


Yes, even this is maybe the easiest way to get things working, it under
certain circumstances (those Lori mentioned) needs user intervention.

Another possibility is to handle this directly inside the Java dll loading
code for a specific directory and if there the requested dll can't be
found,
to fall back to the general dll loading mechanism.

Here is a code fragment which shows what I mean. Note however that in this
example the first place dll loading is JBuilder specific, since it is
taken
from one of my personal custom JB OTs. - For a general Java app, that part
would have been to be substituted with some accessing mechanism for the
current directory the Java app resides in:


private void initTrackpointLibrary() throws Exception
{
String rootDir = JBuilder.getRootDir();
String lib = System.mapLibraryName(DLL_NAME);
Url url =
PropertyManager.getInstallRootUrl().getRelativeUrl("lib/ext");
// <-- JB OTAPI specific part
File libFile = new File( url.getFileObject(), lib );
if (libFile.exists())
{
trace("loading trackpoint.dll form: " +
libFile.getCanonicalPath());
System.load(libFile.getCanonicalPath());
}
else
{
trace("loading trackpoint.dll form java.lib.path");
System.loadLibrary(DLL_NAME);
}

setDebug(conf.debug);
startCaptureTrackpointMessages();
}


-Valentino





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder Deployment All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.