3

Hello stackoverflow community,

I'm using NetBeans IDE 7.2.1, and I'm trying to compile+run a project with native libraries. My libraries require a 32 bit JVM. I'm running Windows 7 64-bit. When attempting to compile+run my project I'm met with the following:

    Error: This Java instance does not support a 32-bit JVM.
    Please install the desired version.
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)

I have tried going to configuration and included the following arguments (to no avail):

    -d32
    -d32 -vm "C:\Program Files (x86)\Java\jre7\bin\javaw.exe" 
    -vm "C:\Program Files (x86)\Java\jre7\bin\javaw.exe"

I have both 64 bit JRE and 32 bit JRE installed, and both a 64 bit JDK and 32 bit JDK available in my platform manager.

Any suggestions to resolve this? I've read that you can get issues by installing the 64 bit JRE before the 32 bit JRE; is this one of those issues? (I have indeed installed 64 bit first)

JoshDM
  • 4,939
  • 7
  • 43
  • 72
Matthew Sutter
  • 33
  • 1
  • 1
  • 4
  • Thank you for the quick response, 11684! Reading what you said I was able to find some more information. In NetBeans I right clicked on the project I was trying to compile, then went to properties > libraries > java platform, and specified my 32 bit JDK. Now to fix other manageable errors :) – Matthew Sutter Mar 01 '13 at 10:33

2 Answers2

2

When you start a process (for example on the command prompt, but it's the same AFAIK when you start another process from code) a certain group of paths (contained in the PATH (?) environment variable) is searched for an executable with a name matching what you entered. If the 64-bit and 32-bit version have the same name and the 64-bit version is found first, that one will be executed. I recommend specifying the full path of the 32-bit JDK.

EDIT:
I just saw the question is about the NetBeans IDE. I've never used that, so the only advice I can give you is to look in NetBeans' settings, and adjust the path to the JDK and JRE, making it point to the 32-bit version. I'll leave my answer here for people not using NetBeans.

11684
  • 7,356
  • 12
  • 48
  • 71
0

Thanks to @11684 for the great answer. I would simply like to add a code example for those who compile from the command line/Command Prompt.

For the compilation, it shouldn't matter which javac gets used - 32-bit or 64-bit.

>javac MyJavaProgramUsing32BitNativeLib.java

For the actual execution of the program, it is important to specify the path to the 32-bit version of java.exe

I'll post a code example for Windows, since that seems to be the OS used by the OP.

Windows

Most likely, the code will be something like:

>"C:\Program Files (x86)\Java\jre#.#.#_###\bin\java.exe" MyJavaProgramUsing32BitNativeLib 

The difference will be in the numbers after jre. To find which numbers you should use, enter:

>dir "C:\Program Files (x86)\Java\"

On my machine, the process is as follows

C:\Users\me\MyProject>dir "C:\Program Files (x86)\Java"
 Volume in drive C is Windows
 Volume Serial Number is 0000-9999

 Directory of C:\Program Files (x86)\Java

11/03/2016  09:07 PM    <DIR>          .
11/03/2016  09:07 PM    <DIR>          ..
11/03/2016  09:07 PM    <DIR>          jre1.8.0_111
               0 File(s)              0 bytes
               3 Dir(s)  107,641,901,056 bytes free

C:\Users\me\MyProject>

So I know that my numbers are 1.8.0_111, and my command is

C:\Users\me\MyProject>"C:\Program Files (x86)\Java\jre1.8.0_111\bin\java.exe" MyJavaProgramUsing32BitNativeLib
bballdave025
  • 1,347
  • 1
  • 15
  • 28