EPFL
 Biomedical Imaging Group
EPFL   Image Processing Lab
English only    BIG > IPLAB > Tutorial > Java Compilers [Top|Previous|Next]
 CONTENTS
Home page
Events
Members
Demos
Teaching
Image Processing Lab
bulletTutorial
bulletSubmission
bulletSession 1
bulletSession 2
bulletSession 3
bulletSession 4
Java Portability

The way to have a portable software it is to produce a code named "bytecode" that is the same, no matter which platform you run it on. You have to use a JVM (Java Virtual Machine) installed in your machine that interprets the bytecode and deals with the platform dependencies.

Bytecode

When you compile a Java source file *.java, the compiler produces bytecode in the *.class file.

Java Code Bytecode
	void whileInt() {
	int i = 0;
	while (i < 100) {
		i++;
	}
			
	Method void whileInt()
	0 iconst_0
	1 istore_1
	3 goto 8
	5 iinc 1 1
	8 iload_1
	9 bipush 100
	11 if_icmplt 5
	14 return

Java Virtual Machine

When you execute the file that contains this bytecode, you have to use a specific JVM that interprets the bytecode. By this way, the same Java program compiled on one platform can run on all platforms with a JVM.

The JVM is free. There is also a JVM embedded within the recent browsers that allows to run a special class of Java applications named applets. Matlab integrates also a JVM and can execute the bytecode.

The disadvantages of the Java Virtual Machine concept are:

  • It can be slower than C for example. In practice, however current processors are fast enough for the difference to be imperceptible.
  • There are many JVM available. They should be strictly compliant with Sun's specifications. Unfortunately, that is far from being the case.