you simply created the class HelloWorld, but in Eclipse you have to create the project first. Select File ➪ New ➪ Java Project and enter Hello as the name of the project in the pop-up window,
as shown in Figure
You can select the version of the JRE you want to work with. In this lession I’ve installed the JDK and JRE of version 1.6.0_19, but you may have more than one version of JRE, and Eclipse can compile the code that will run in another version of JRE. This is a pretty nice feature of Eclipse IDE — it doesn’t come with its own JRE, but it allows you to pick the version that fits your needs. In some cases you have to compile the code with older versions of JRE if you know that this program will have to run in the older JVMs.
![]() |
Don’t change the name of the output directory — just click Finish on that window. In Figure you see a new project, Hello, in the Package Explorer view of Eclipse.
This project has an empty folder, src — youcan save the source code of HelloWorld.javathere when ready. The JRE folder contains all required libraries supporting the JVM where HelloWorld will run.
These library files have .jar in their names. Java SDK comes with a jar utility that allows you to create a file archive that contains one or more compiled classes. While the JRE folder contains classes created by developers of the JRE itself, most real-world applications consist of groups of files (packages) located in
one or more jars.
It doesn’t make much sense to put the only HelloWorld class inside the jar, but as your sample applications grow, you’ll see how to group and compress files in jars.


No comments:
Post a Comment