0

I am developing a Java program that calls a 32-bit CPLEX Optimizer,
But I will run this code on a 64-bit machine.
Can I run part of program in 64-bit and other parts in 32-bit?

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

3

If it's a separate program that runs in its own process, there's no problem. 32-bit and 64-bit processes can coexist on the same system.

If it's a Java library that loads a 32-bit native library into the JVM (e.g. with JNI), it'll only work in a 32-bit JVM process.

Wyzard
  • 33,849
  • 3
  • 67
  • 87
  • Command for what? There's no magic pill that makes 32-bit libraries work in 64-bit processes, if that's what you're asking. You could try running the optimizer in a separate 32-bit JVM process, alongside the 64-bit one, and have the two JVMs communicate using something like RMI. – Wyzard Apr 11 '12 at 04:19
  • Once you install a 32 bit JRE on your system you need to configure your IDE to use it. For Eclipse instructions check out http://stackoverflow.com/a/327661/1118307 . – vpiTriumph Apr 11 '12 at 04:21
  • i actually want to run this program in 64bit. i install 64bit java.ans set net beans to use 64bit jdk, but when calling the cplex library show error. may exit some command to temporary convert to 32bit? – mehdi fallahi Apr 11 '12 at 05:28
  • @mehdifallahi You can "convert" a 32-bit shared library by re-compiling it from source as a 64-bit library. (Plus fix any bugs in the code as this is not always trivial) If this sounds like a headache, it is the sort of headache that Java is designed to solve. – Peter Lawrey Apr 11 '12 at 05:58
  • @PeterLawrey, that only works if you have the source code. In this case it seems to be a third-party commercial library. – Wyzard Apr 11 '12 at 06:16
  • @mehdifallahi, no, there's no command to "temporarily convert" a 64-bit process into a 32-bit process. They're different instruction sets and different memory layouts. If the vendor doesn't provide a 64-bit version of the library you're using, you'll need to use the workaround with a separate 32-bit JVM. (Or just run your whole application in a 32-bit JVM.) – Wyzard Apr 11 '12 at 06:21
  • @Wyzard The vendor will have the source. I assume that OP knows that he can't compile the source if he doesn't have it. ;) – Peter Lawrey Apr 11 '12 at 07:17
0

To use a 32-bit shared library from a 64-bit process you need to have two processes. One which has your 64-bit JVM which calls a 32-bit process which holds your shared library.

The other option is to recompile your shared library from source as a 64-bit library.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130