Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

32Bit Native Code, JNA and a 64Bit JVM

I'm developing a java application, using a 32Bit native library which I'm accessing via JNA. On MacOS X Snow Leopard it's possible to pass the parameter "-d32" to the JVM, which causes the JVM to start in 32Bit mode. I've got a launcher application, which sets some environment variables and then starts the main application. This is also the place where it is decided to launch the main application with the -d32 switch, if the program is executed on MacOS.

So here's my question: Is there a similar way to solve this on Windows or Linux?

It would be the best if it was possible to run the 64Bit JVM in 32Bit mode. But I'm not really afraid to tell my users to install an additional 32Bit JVM, that's not the problem. The problem is, that I would have to tell my launcher application where the 32Bit JVM can be found, as the first one in the PATH variable could be the 64Bit one.

Thanks in advance,

aRestless

like image 820
aRestless Avatar asked May 29 '11 18:05

aRestless


1 Answers

If you bundle the 32-bit JVM with your application, it can run fully independent of any installed JRE and system path. This is allowed by Java SE 6: http://java.sun.com/javase/6/jdk-6u2-license.txt. You can also start JVM by loading jvm.dll, thus showing only your launcher image in task manager. You can even avoid writing a native launcher at all if you use WinRun4J: http://winrun4j.sourceforge.net/

Hope that helps!

like image 71
fernacolo Avatar answered Sep 30 '22 23:09

fernacolo