5

My Java application has a requirement to use a 32 bit native library on OSX.

Specifically I have a 32 bit ODBC driver and have some JNI code to use the driver, but there doesn't appear to be any 32 bit Java 7 JVM that will run on OSX.

I do not have the source code for the driver, so I cannot recompile it.

There is no JDBC driver for this product, which is why I am using ODBC.

I've looked around for 32 bit OpenJDK ports but the only project that might have supported it is dead.

Does anyone have any ideas?

Eric Milas
  • 1,807
  • 2
  • 18
  • 29
  • Can you please clarify what you mean by "native library"? Does ODBC need a 32-bit JVM or just a certain library in 32-bit? – Max Leske Nov 01 '13 at 20:45
  • This is probably a duplicate. See http://stackoverflow.com/questions/15111743/java-7-to-be-run-in-32-bit-on-mac and in particular http://stackoverflow.com/questions/15111743/java-7-to-be-run-in-32-bit-on-mac – Max Leske Nov 01 '13 at 20:49
  • The driver itself 32 bit, my understanding is that only 32 bit applications can use it. So my JNI layer is compiled for 32 bit as well. Java will not use that component. It throws an UnsatisfiedLinkError with the detail "mach-o, but wrong architecture" – Eric Milas Nov 01 '13 at 20:50
  • Unfortunately the Java code is written for Java 7. I will revert the code and use the Apple JDK 6 if I have to, but I would rather not get stuck on Java 6 forever. I am hoping that there are some other alternatives. – Eric Milas Nov 01 '13 at 20:53
  • Did you read the questions I linked to? One of them tells you how to make the JRE run in 32-bit mode. – Max Leske Nov 01 '13 at 20:55
  • The other articles I have read say that the -d32 flag is not supported in the Java 7 JVM, but I will look into it more. – Eric Milas Nov 01 '13 at 20:58
  • 2
    A native library without source is going to become unstuck at some point. I suggest you come up with a migration plan where you don't have to use this driver. – Peter Lawrey Nov 01 '13 at 21:00
  • 1
    I have confirmed that the -d32 flag is not supported in the Mac Java 7 HotSpot JVM. So this is not a duplicate of http://stackoverflow.com/questions/6942063/how-to-run-32-bit-java-on-mac-osx-10-7-lion – Eric Milas Nov 01 '13 at 21:09
  • 1
    @PeterLawrey I completely agree, unfortunately I don't have many options on that front right now. I do not have control over the system we are interacting with. – Eric Milas Nov 01 '13 at 21:19
  • 3
    It seems [this](http://stackoverflow.com/questions/2412893/making-a-64-bit-shared-library-that-dynamically-links-to-a-32-bit-library-on-mac) is your only option. Time-consuming and a hassle, but if you gotta do it, you gotta do it. Otherwise, go back to Java 6 and know that you will be there until you can replace the library. Writing a JDBC driver might be easier. – brettw Nov 09 '13 at 06:59

1 Answers1

2

I think the only answer for you (on JDK 7) is to use OBuildFactory to compile a 32-bit jdk. This question was similar and pointed me to these directions.

Community
  • 1
  • 1
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
  • 1
    This does appear to be a viable solution. Based on the research I have done, it would take quite a bit of effort to get a 32-bit build created, but it is possible as the owner of the project used to release them. He stopped working on Macs and didn't have time to maintain the releases anymore. It appears that others either have created 32-bit builds or are actively working on them. Hopefully those people will contribute to the project. I am not going to go down that road at this time (I've already begun work on an alternative solution) but I think it will work so I will accept the answer. – Eric Milas Nov 12 '13 at 02:55