We also have the resources files, as for example, the sounds of our aplication. "C:\Program Files (x86)\Java\jdk1.6.0_27\bin\java" HelloWorldĪ java program is made up of several java files and consequently several *.class files. We can execute this bytecode with the following instruction: "C:\Program Files (x86)\Java\jdk1.6.0_27\bin\javac" HelloWorld.javaĪs a result we can see that a new file HellowWorld.class has been created with the bytecode. We open a command window, we execute "cd C:\testjava" to locate us in the directory where our java file is and to compilate we execute: javac HelloWorld.java JOptionPane.showMessageDialog(null, "Hello World") To show how these programs work, we are going to create a file called HelloWorld.java in a directory C:\testjava with the following content: import Inside JAVA_HOME there is a folder bin which contains the executable with the compilator: javac.exe and the virtual machine: java.exe. This directory is known as java Home or JAVA_HOME. If we have the JDK installed, we have a directory with all the files which make up the java platform. If you don´t have the JDK version installed, you should install it to be able to continue with this tutorial. JDK Java Development Kit contains the JVM, the java compilator and other aditional tools for the development of java aplications. JRE Java Runtime Environment, is a reduced version which contains the JVM, but doesn´t include the java compilator. There are two installation versions for java for each operative system JRE and JDK. The following famous sentence is based in this idea: "Write once, run anywhere" (WORA). For each different operative system there will be a specific virtual machine program but the bytecode executed will be the same.Īs the bytecode is potentially the same, it can be executed in any operative system when there is an implementation of the JVM for that operative system. A virtual machine is a program which works as if it was a machine. This bytecode can only execute on a virtual machine. We obtain a code called bytecode which doesn´t execute directly on a real machine. In the case of java, when we use the compiler, we don´t obtain machine code. That is why we need a different compiler for each machine. A machine with Windows and a Mac of Apple talk different machine language. The "machine language" or "machine code" is the language which the machine understands. Before Java, we wrote a program in a high level programming language like C or Pascal and then we had to translate it to machine language with a compiler.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |