I have been doing a bunch of Struts and REST development in Eclipse for which there are good wizards to get started, but it was suprizingly difficult figure out how to build just a simple hello world java project.
With the help of Nathan, I can now do the basic java project:
First, select the new button just below File and open a new Java Project
![](http://www.johnhufnagel.com/uploaded_images/Image1-796667.jpg)
A New Java Project window will open: enter the name of the project then click Finish
![](http://www.johnhufnagel.com/uploaded_images/Image2-706623.jpg)
You should now see your project listed in the Package Explorer. Expand the project.
![](http://www.johnhufnagel.com/uploaded_images/Image3-735828.jpg)
![](http://www.johnhufnagel.com/uploaded_images/Image4-761996.jpg)
Under the project you will see the project’s package (src) and the library it is referencing. You now want to add a class to the project where you can write your program. So right click the package (src), select new -> class.
![](http://www.johnhufnagel.com/uploaded_images/Image5-786048.jpg)
The New Java Class window opens. Notice the Source Folder. Type the name of the new class and ensure “public static void main(String[] args)” is selected. Click finish to create the class.
![](http://www.johnhufnagel.com/uploaded_images/Image6-786073.jpg)
Because we selected the option to create the main, the IDE automatically inserts its declaration into the code. Now we can begin to write our basic program right away.
![](http://www.johnhufnagel.com/uploaded_images/Image7-775442.jpg)
Replace the comment with this text:
String printStr = "This is your conscience speaking..."; System.out.println(printStr);
In the Package Explorer, right click the class and select Run As to run the program. If a message box appears, select yes to save the project. You will see the text printed to the screen.
![](http://www.johnhufnagel.com/uploaded_images/Image8-775460.jpg)
No comments:
Post a Comment