How do you think set the PATH in Windows 7 64bit to have access to both 32 and 64 bit compilers. I have noteiced that appart from different folders everything such as java.exe, javac.exe, etc. are exactly the same. I believe the first path in the PATH variable (either with 32bit binaries or the 64bit) will take precedence.
My idea would be to change 64bit compiler's name (java.exe) and class execute program's name (javac.exe) and le't say add 64bit postfix but I am not sure if that would work. Please advice.
Thanks in advance.
java is not the compiler, that's javac. Also, the compiler generates the same byte-code on 64-bit as it does on 32-bit. Assuming you are using pure Java, the only distinction is in the run-time (or JRE) where a 64-bit JRE can address more memory. If you have native code then you must match the settings those libraries were compiled with . But, in general, if you are on a 64-bit system with more then 4 gigabytes of memory, only a 64-bit JRE can use the extra memory.
Related
Here are some details about my system:
Windows 7 (64-Bit)
JDK 1.8.0_05 (64-Bit)
JDK 1.7.0_51 (32-Bit)
Eclipse - Luna 4.4.0 (64-Bit)
Although my eclipse uses the 64-bit version of Java, I want to compile a Java program using the 32-bit version through the terminal.
Any suggestions how I can do that?
If you find that the Windows or Linux or Mac or 32-bit or 64-bit compiler produces a different output, this is most likely a bug (unless the compiler runs out of memory) Note: Eclipse has it's own compilers and it might generate different .class files. Usually this doesn't matter however when it does it can lead to subtle inconsistencies. I would make sure you always use the Oracle or IBM compiler if you can to avoid these issues.
However, you can specify the bit-ness in the same way you specify the version by setting the PATH or using the whole path when you run it. If you use an IDE, this is what it does for you, and many, many other things.
so the questions as in the title, I need to run my server application in Tomcat on a System which is 32 bit Windows XP, I am working and compiling on my 64 bit Windows 7 in Eclipse. How do I compile it to 32 bit, what do I need to do? I assume it won't work on the 32 bit Windows when I'm compiling it on a 64 bit machine?
Java doesn't build 32-bit or 64-bit applications - bytecode is portable across different bit architectures.
The only exception is native libraries that you might be using in your code. If there are any then you will have to manually compile those for the respective platform. Otherwise the java code is totally portable across 32-bit and 64-bit platforms.
The problem is your JNI DLL, which needs to be compiled for 32-bit to match the 32-bit JRE.
Java is independent of the OS.
You can compile with your 64bit machine and run this on a 32bit computer as long as this computer has a 32bit VM.
If you're still searching for some "simple" solution, one would be to install a 32 bit os in a virtual machine and run eclipse from there.. Very ugly I know, but it works.
Another approach is mentioned here. How to launch java swing app which used precompled DLL from cmd?
You could install a 32bits jdk on a 64bits machine. point the JAVA_HOME to this jdk and use it. It
Can 32 bit native DLL be loaded from 64 bit JRE? If not what is the best solution?
Should user install both 32 and 64 bit versions of JRE?
Thank you.
Both 32-bit and 64-bit versions of the JRE would need to installed and used accordingly. Note, this is not requirement of the JRE but of Windows. From Programming Guide for 64-bit Windows:
... 32-bit processes cannot load 64-bit DLLs for execution, and 64-bit processes cannot load 32-bit DLLs for execution.
If you want to use a 64-bit JVM but have a 32-bit DLL you need to use, you can run both and have the 64-bit JVM talk to the 32-bit JVM when it needs to the DLL to do something.
I'm using Launch4J to start my Java application and if an x64 JRE is present on the system, Launch4J seems to prefer it.
Unfortunately my application cannot run on a 64 bit JVM because I'm loading a 32 bit DLL, which is not possible and leads to an UnsatisfiedLinkError.
Is there any way to force/trick Launch4J to use a 32 bit JVM only?
I have exactly the same problem : Into 64 bits environment if both 32 ans 64 bits JDK/JRE are installed this tools always detect the 64 bits version.
I have patched the source (java + C++) code to make my own version and re-compile all. I add a check box to FORCE the 32 bits JDK/JRE detection into 64 bits windows environment.
Just donwload the version and use it as the original one.
Version : launch4j-3.0.2-win32_Java32bitsDetection
I had this exact problem about a year ago, using Lauch4J to wrap a small Java program that required a 32-bit DLL (swt-win32.dll, as it happened).
I found that if there were 32-bit and 64-bit JVMs installed, Launch4J would always favour the 64-bit one. It would only work if the 64-bit JVM was uninstalled, which was obviously not a practical solution.
I found no way of getting Launch4J to prefer (and require) the 32-bit JVM, after searching quite a bit and posting questions on its forum.
Therefore, I evaluated a good number of alternative JRE converters (I used this list: http://www.excelsior-usa.com/articles/java-to-exe.html).
I ended up settling on Jar2Exe, which was the only one that had the features I needed. It's not free, though there is an evaluation version, and I think it wasn't expensive.
Hope this helps!
I don't know Launch4J, but you can get the Information about 32/64 by reading System.getProperty("os.arch");. If you encounter a 64-bit system you may quit the installer with a nice message, to tell the User to install a 32-bit JVM.
You may Wrap your startUp-Code with an Wrapper to show a Message-Box to the user.
public static void main(String[] args]){
String architecture = System.getProperty("os.arch");
// Did not test the return value of this property,,but should work
if("64".equals(architecture)){
// Show a dialog, or print a logmessage
System.exit(-1);
}
// Start my APP
com.something.startup.main(args);
}
If you don't mind including a copy of JDK with your app, try passing these arguments (in the MyApp.ini) to launch4j:
-D32 -Djava.home=d:\MyApp\JDK32 -Djava.ext.dirs=d:\MyApp\JDK32\jre\lib\ext
There are also other things going on here that you could use:
If you don't package the JRE, you can set the Launch4j option to use "jreOnly" and then, using the DOS environment variable called "%ProgramFiles%" you can locate the 32-bit or the 64-bit JRE in the expected location, depending on whether you used the SysWOW64 32-bit cmd.exe shell or the regular 64-bit shell. Then you can pass these options to the JVM:
-D32 -Djava.home=%ProgramFiles%\Java\JREDIR -Djava.ext.dirs=%ProgramFiles%\Java\JREDIR\lib\ext
or
-D32 -Djava.home=%ProgramFiles(x86)%\Java\JREDIR -Djava.ext.dirs=%ProgramFiles(x86)%\Java\JREDIR\lib\ext
I encountered the same problem some time ago and forked the project, so that the User interface exposes an option to force that a 32bit JVM ought to be found, you can grab the installer of launch4j 3.0.3 with the patch from:
http://fbergmann.github.io/launch4j/files/SetupLaunch4j_3.0.3.exe
and read more here:
http://frank-fbergmann.blogspot.de/2012/11/launch4j-for-32bit.html
http://fbergmann.github.io/launch4j/
This is an old question and Launch4J has been updated since it was asked. Now there is a dedicated user-interface control for selecting which version of the JVM to prefer.
The options currently are:
64-bit only
First 64-bit, then 32-bit
First 32-bit, then 64-bit
32-bit only
The last, one of course, is exactly what the OP requested.
For any users of Launch4j applications like Areca that get stung by this one, and need a quick work around, look in the directory where the application is launched and you will find a complete java command line to run your program inside a file named launch4j.log. Just make a bat file or script using the java vm you prefer and run it with the full command line in the log.
You will have to add a JVM parameter while configuring.
It is shown in the below post on how to add it:
http://www.technimi.com/index.php?do=/group/java/forum/building-an-exe-using-launch4j-for-32-bit-jvm/
How do I tell if I am using 64-bit Eclipse and 64-bit JVM on my Linux machine?
To verify that you are using 64-bit JVM:
java -d64 -version
In a comment above you say that you're using a software package that requires "such constraints". I'm not exactly sure what you mean by that, but for Java programs, it doesn't matter if the underlying Java implementation is 32-bit or 64-bit (well, as long as it doesn't need a huge amount of memory, for example). A normal Java program should run the same, no matter if it runs on a 32-bit or 64-bit OS.
java -version should give you an indication if your Java runtime environment is 32-bit or 64-bit.
Eclipse contains some native binaries (for the SWT libraries). Depending on if your Java runtime environment is 32-bit or 64-bit, you need a version of Eclipse with the corresponding native binaries. The Eclipse download page contains links for 32-bit and 64-bit Linux versions of Eclipse.
Note: If your OS is 64-bit but your Java RE is 32-bit, you will still need the 32-bit Eclipse.
Usually you can tell from your eclipse.sh or your eclipse.ini if you are using 32bit or 64bit version, as the involved plugins are quite different.
As for the JVM, are you running Eclipse with something other than your default JVM? 'which java' usually tells you what you're using as your java executable.