Jump to content
Excelsior Forums
shashaank

Jet 9.0 MP2 relative classpath issue

Recommended Posts

Hi,

-----------Edit---------------

It seems that this issue is not caused by upgrading to Excelsior MP2.

Basically, it seems the absolute path of the executable is not known to the runtime. It just knows the directory from which it was called.

I have 2 ways out

(1) Extract dll to temp folder each and everytime, and load it from there

(2) Somehow package the dll to into the exe. But I don't know how to do it with excelsior.

Kindly advice, how I may load my dlls, when my program is

invoked from a location which is NOT the directory where the exe exists.

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

My program dynamically loads a dll located relative to the resultant executable created using excelsior.

The

Application working directory : F:\neembuu\release1_development_environment

Location of the dll which is loaded during runtime : f:\neembuu\release1_development_environment\lib\jpfm_x86_rev113.dll

I resolve the path by first locating the jar file, and then find the dll relative to it.

The code used to find the jar looks like this:

       String fullLibraryPath = DefaultManager.class
               .getProtectionDomain().getCodeSource().
               getLocation().toString();
       LOGGER.log(Level.INFO, "DefaultManager codesource path {0}", fullLibraryPath);

When I run the program from the application working directory, the location of the source I get :

INFO: DefaultManager codesource path file:/F:/neembuu/release1_development_environment/lib/jpfm.jar

When I run the program from working directory, say f:\ , using the command

F:\>\neembuu\release1_development_environment\neembuu-now.exe

I get the following output

INFO: DefaultManager codesource path file:/F:/lib/jpfm.jar

In case the program is run from any directory other than the application working directory

the location of code is incorrectly specified. This makes loading the dll impossible.

I think my best bet would be to package the dll into the application itself.

And simply call the System.load("jpfm_x86_rev113");

But that would make the code very specific to windows, x86, and excelsior jet and very ugly.

The last time I compiled all this was working fine.

Probably I should reinstall the old version of jet and try again.

When the same thing is run using xjava -jar command the behavior is consistent with my expecations.

Compatibility is breaking when I compile it to an exe.

Any suggestion?

If is this behavior normal? Or I am doing it all wrong?

Thanks :)

PS: I am not sure if this is an issue because of upgrading to Jet9.0 MP2,

but it wasn't the case earlier. I might be wrong, so please correct me in that case.

Share this post


Link to post
Share on other sites

It's a known issue (for jar files compiled in the "pack into exe" mode) and it will be fixed in the next release (Dec 2014).

For now, you can either:

- get code source from a class residing in a jar not packed into exe, if any; or

- define your own VM options and use its for loading the library (if you define its value as $(Root)in JetPackII, it will hold the path to installation directory)

Share this post


Link to post
Share on other sites

It's a known issue (for jar files compiled in the "pack into exe" mode) and it will be fixed in the next release (Dec 2014).

For now, you can either:

- get code source from a class residing in a jar not packed into exe, if any; or

- define your own VM options and use its for loading the library (if you define its value as $(Root)in JetPackII, it will hold the path to installation directory)

Thank you. For now I made heavy changes in the way the library is detected and solved the problem without breaking compatibility with Oracle JVM.

What I did was I implemented multiple fallbacks in the code. The code first looked for the dll in the expected location. If it failed, it did something else, and so on. I also placed a copy of the dll in the root directory where excelsior always looks for libraries. This way I somehow got it working.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×