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
What is the difference between JVM, JDK, JRE & OpenJDK?
I was programming in Java and I encountered these phrases, what are the differences among them?
JVM
The Java Virtual Machine (JVM) is the virtual machine that runs the Java bytecodes. The JVM doesn't understand Java source code; that's why you need compile your *.java files to obtain *.class files that contain the bytecodes understood by the JVM. It's also the entity that allows Java to be a "portable language" (write once, run anywhere). Indeed, there are specific implementations of the JVM for different systems (Windows, Linux, macOS, see the Wikipedia list), the aim is that with the same bytecodes they all give the same results.
JDK and JRE
To explain the difference between JDK and JRE, the best is to read the Oracle documentation and consult the diagram:
Java Runtime Environment (JRE)
The Java Runtime Environment (JRE) provides the libraries, the Java Virtual Machine, and other components to run applets and applications written in the Java programming language. In addition, two key deployment technologies are part of the JRE: Java Plug-in, which enables applets to run in popular browsers; and Java Web Start, which deploys standalone applications over a network. It is also the foundation for the technologies in the Java 2 Platform, Enterprise Edition (J2EE) for enterprise software development and deployment. The JRE does not contain tools and utilities such as compilers or debuggers for developing applets and applications.
Java Development Kit (JDK)
The JDK is a superset of the JRE, and contains everything that is in the JRE, plus tools such as the compilers and debuggers necessary for developing applets and applications.
Note that Oracle is not the only one to provide JDKs.
OpenJDK
OpenJDK is an open-source implementation of the JDK and the base for the Oracle JDK. There is almost no difference between the Oracle JDK and the OpenJDK.
The differences are stated in this blog:
Q: What is the difference between the source code found in the OpenJDK repository, and the code you use to build the Oracle JDK?
A: It is very close - our build process for Oracle JDK releases builds on OpenJDK 7 by adding just a couple of pieces, like the deployment code, which includes Oracle's implementation of the Java Plugin and Java WebStart, as well as some closed source third party components like a graphics rasterizer, some open source third party components, like Rhino, and a few bits and pieces here and there, like additional documentation or third party fonts. Moving forward, our intent is to open source all pieces of the Oracle JDK except those that we consider commercial features such as JRockit Mission Control (not yet available in Oracle JDK), and replace encumbered third party components with open source alternatives to achieve closer parity between the code bases.
Update for JDK 11
An article from Donald Smith try to disambiguate the difference between Oracle JDK and Oracle's OpenJDK : https://blogs.oracle.com/java-platform-group/oracle-jdk-releases-for-java-11-and-later
As mentioned in comments by #Alan Evangelista, Java Web Start has been deprecated by Oracle in Java SE 9 and removed in Java SE 11.
JVM is the Java Virtual Machine – it actually runs Java ByteCode.
JRE is the Java Runtime Environment – it contains a JVM, among other things, and is what you need to run a Java program.
JDK is the Java Development Kit – it is the JRE, but with javac (which is what you need to compile Java source code) and other programming tools added.
OpenJDK is a specific JDK implementation.
JDK (Java Development Kit)
Java Developer Kit contains tools needed to develop the Java programs, and JRE to run the programs. The tools include compiler (javac.exe), Java application launcher (java.exe), Appletviewer, etc…
Compiler converts java code into byte code. Java application launcher opens a JRE, loads the class, and invokes its main method.
You need JDK, if at all you want to write your own programs, and to compile them. For running java programs, JRE is sufficient.
JRE is targeted for execution of Java files
i.e. JRE = JVM + Java Packages Classes(like util, math, lang, awt,swing etc)+runtime libraries.
JDK is mainly targeted for java development. I.e. You can create a Java file (with the help of Java packages), compile a Java file and run a java file.
JRE (Java Runtime Environment)
Java Runtime Environment contains JVM, class libraries, and other supporting files. It does not contain any development tools such as compiler, debugger, etc. Actually JVM runs the program, and it uses the class libraries, and other supporting files provided in JRE. If you want to run any java program, you need to have JRE installed in the system
The Java Virtual Machine provides a platform-independent way of executing code;
That mean compile once in any machine and run it any where(any machine).
JVM (Java Virtual Machine)
As we all aware when we compile a Java file, output is not an ‘exe’ but it’s a ‘.class’ file. ‘.class’ file consists of Java byte codes which are understandable by JVM. Java Virtual Machine interprets the byte code into the machine code depending upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc… JVM is platform dependent.
The JVM is called “virtual” because it provides a machine interface that does not depend on the underlying operating system and machine hardware architecture. This independence from hardware and operating system is a cornerstone of the write-once run-anywhere value of Java programs.
There are different JVM implementations are there. These may differ in things like performance, reliability, speed, etc. These implementations will differ in those areas where Java specification doesn’t mention how to implement the features, like how the garbage collection process works is JVM dependent, Java spec doesn’t define any specific way to do this.
A Java virtual machine (JVM) is a virtual machine that can execute Java ByteCode. It is the code execution component of the Java software platform.
The Java Development Kit (JDK) is an Oracle Corporation product aimed at Java developers. Since the introduction of Java, it has been by far the most widely used Java Software Development Kit (SDK).
Java Runtime Environment, is also referred to as the Java Runtime, Runtime Environment
OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java programming language. It is the result of an effort Sun Microsystems began in 2006. The implementation is licensed under the GNU General Public License (GPL) with a linking exception.
JVM is the virtual machine Java code executes on
JRE is the environment (standard libraries and JVM) required to run Java applications
JDK is the JRE with developer tools and documentations
OpenJDK is an open-source version of the JDK, unlike the common JDK owned by Oracle
JDK (Java Development Kit) :
contains tools needed to develop the Java programs.
You need JDK, if at all you want to write your own programs, and to compile them.
JDK is mainly targeted for java development.
JRE (Java Runtime Environment)
Java Runtime Environment contains JVM, class libraries, and other supporting files.
JRE is targeted for execution of Java files.
JVM (Java Virtual Machine)
The JVM interprets the byte code into the machine code depending upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc… Java Virtual Machine provides a platform-independent way of executing code.
JDK - Compiles java to ByteCode. Consists of debuggers, Compilers etc.
javac file.java // Is executed using JDK
JVM - Executes the byte code. JVM is the one which makes java platform independent. But JVM varies for platforms.
JRE - JVM along with java runtime libraries to execute java programs.
JVM : A specification which describes the the way/resources to run a java program. Actually executes the byte code and make java platform independent. In doing so, it is different for different platform. JVM for windows cannot work as JVM for UNIX.
JRE : Implementation of JVM. (JVM + run time libraries)
JDK : JRE + java compiler and other essential tools to build a java program from scratch
Another aspect worth mentioning:
JDK (java development kit)
You will need it for development purposes like the name suggests.
For example: a software company will have JDK install in their computer because they will need to develop new software which involves compiling and running their Java programs as well.
So we can say that JDK = JRE + JVM.
JRE (java run-time environment)
It's needed to run Java programs. You can't compile Java programs with it .
For example: a regular computer user who wants to run some online games then will need JRE in his system to run Java programs.
JVM (java virtual machine)
As you might know it run the bytecodes. It make Java platform independent because it executes the .class file which you get after you compile the Java program regardless of whether you compile it on Windows, Mac or Linux.
Open JDK
Well, like I said above. Now JDK is made by different company, one of them which happens to be an open source and free for public use is OpenJDK, while some others are Oracle Corporation's JRockit JDK or IBM JDK.
However they all might appear the same to general user.
Conclusion
If you are a Java programmer you will need JDK in your system and this package will include JRE and JVM as well but if you are normal user who like to play online games then you will only need JRE and this package will not have JDK in it.
In other words JDK is grandfather JRE is father and JVM is their son.
Developers develop using JDK, and first we write .java source code
Developers debug the code and compile the code into .class bytecode executable files in JRE
The executable files are executed by JVM, translating the bytecode into native machine code which machines can execute
Here is they relations:
Reference:
Java JDK, JRE and JVM
Java is the language and includes a strict and strongly typed syntax.
Java 2 Platform, Standard Edition, also known as J2SE, referred to the platform and included the classes in the java.lang and java.io packages, among others. It was the building block that Java applications were built upon.
A Java Virtual Machine, or JVM, is a software virtual machine that runs compiled Java code. Because compiled Java code is merely bytecode, the JVM is responsible for compiling that bytecode to machine code before running it. (This is often called the Just In Time Compiler or JIT Compiler.) The JVM also takes care of memory management so that application code doesn’t have to.
The Java Development Kit, or JDK, was and remains the piece of software Java developers use to create Java applications. It contains a Java language compiler, a documentation generator, tools for working with native code, and (typically) the Java source code for the platform to enable debugging platform classes.
The Java Runtime Environment, or JRE, was and remains the piece of software end users download to run compiled Java applications. It includes a JVM but does not contain any of the development tools bundled in the JDK. The JDK, however, does contain a JRE.
JVM : this actually means the byte code interpreter .It is platform dependent. For eg: in Windows platform the 'java.exe' or 'javaw.exe' precess is the jvm process.
JDK : is a toolkit containing necessary libraries and utilities to develop and execute java program/application
JRE: is the execution environment for a java application.ie, it only support runtime dependencies including jvm for compiled program. If we want to compile a java program we need jdk.
JVM : virtual machine of java. tells machine what to do with the Java Code. You cannot download JVM as is. It comes packaged in some other component.
JRE: Some other component referred as above is the JRE.
It is JVM+ other jars to create runtime environmeny
JDK: contains JRE(which in turn contains JVM). Once you get JDK you need not install JRE and JVM separately. It contains compiler which compiles your .java files to .class files
JVM
JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime environment in which java bytecode can be executed.
JVMs are available for many hardware and software platforms.
JRE
JRE is an acronym for Java Runtime Environment.It is used to provide runtime environment.It is the implementation of JVM.It physically exists.It contains set of libraries + other files that JVM uses at runtime.
JDK
JDK is an acronym for Java Development Kit.It physically exists.It contains JRE + development tools.
Link :- http://www.javatpoint.com/difference-between-jdk-jre-and-jvm
In summary:
JRE = JVM + Java Packages (like util, math, lang, awt, swing etc) +
runtime libraries
JDK = JRE + Development/debugging tools
If you want to develop in java, you need the JDK, but if you just want run java, you need the JRE.
Simple image to illustrate JDK, JRE, JDK.
JDK In general this will be installed only in development setups like in developers, QA systems in real-time at corporate companies. Original code which is running in servers will not have JDK.
JRE is a part of JDK and independently too installable in servers. In real-time servers which serving user requests will have only JRE installed and code developed by developers (in *.class format)
JVM Developer developed code > tested and executed in development machines. Execution phase require a medium for Java.
.class files are not native code (code which understands by cpu). To achieve WORA (Write Once Run Anywhere) concept can't be achieved if .java file is directly converted to native code.
Native code differs from OS to OS. So, Java created a intermediate file called .class and magical program called "JVM". Its JVM's duty to convert .class into native code.
JVM Java Virtual Machine , actually executes the java bytecode.
It is the execution block on the JAVA platform. It converts the bytecode to the machine code.
JRE Java Runtime Environment , provides the minimum requirements for executing a Java application; it consists of the Java Virtual Machine (JVM), core classes, and supporting files.
JDK Java Development Kit, it has all the tools to develop your application software. It is as JRE+JVM
Open JDK is a free and open source implementation of the Java Platform.
In layman terms:- JDK = JRE + Development/debugging tools, where JDK is our complete package to work with Java, from creating compiling till running it.On the other hand JRE is just of running of code(Byte Code).
Note:- Whether we are installing JDK or JRE, JVM would come bundled with both the packages and JVM is the part where JIT compiler converts the byte code into the machine specific code.
Just read the article on JDK,JRE ,JVM and JIT
JDK: The complete package which you need to write and run java code
OpenJDK: An independent implementation of JDK for making it much better
JVM: Converts Java code into bytecode and provides the specifications which tells how should a Java code be compiled, loaded, verified, checked for errors and executed.
JRE: Implementation of the JVM with which some Java libraries are used to Run the program
JRE executes the application but JVM reads the instructions line by line so it's interpreter.
JDK=JRE+Development Tools
JRE=JVM+Library Classes
JVM is abbreviated as Java Virtual Machine, JVM is the main component of java architecture. JVM is written in C programming language. Java compiler produce the byte code for JVM. JVM reading the byte code verifying the byte code and linking the code with the ibrary.
JRE is abbreviated as Java Runtime Environment. it is provide environment at runtime. It is physically exist. It contain JVM + set of libraries(jar) +other files.
JDK is abbreviated as Java Development Kit . it is develop java applications. And also Debugging and monitoring java applications . JDK contain JRE +development tools(javac,java)
OpenJDK OpenJDK is an open source version of sun JDK. Oracle JDK is Sun's official JDK.
JDK - Tools like javac used to compile *.java files to *.class bytecode files (basically develop Java programs)
JRE - Tools to run *.jar files (basically run Java programs)
JVM - Tools to compile *.class files to executable machine code (run all Java bytecode)
OpenJDK is just a distribution of the Java JDK.