To begin, startup Eclipse. You can do this by typing in eclipse & into the command prompt
Once Eclipse starts up, if you see this welcome screen, click on the workbench button.
Next, you will be asked to select a workspace. This is important! This is the root directory to which all of your programs will be saving to, so make sure you know where it is. In my case, I clicked Browse... and created a directory called EECS2030.
Now we need to create a Java Project. You can do this by doing: File -> New... -> Project... -> Java Project. The project wizard looks like this - click on Java Project.
Now, you will see a window like the one shown. I have named my project 'Tutorial'. You can name your project whatever you like. Note that doing this now creates a directory in your previously created workspace directory. Keep the default settings and click finish.
You may then see a popup window like the one showed here. Click Yes if that is the case.
The next step is to create a package. To do this, right-click the new project you just created that will now appear in the Package Explorer on the left side, and then click New -> Package. I will name the package EECS2030.
Packages are nothing more than directories. So just now, I created yet another
directory. This will be useful for when your projects become very large.
Also, note that there is a naming convention for packages that we are not
demonstrating here. To learn more about packages, refer to this
Java Tutorial.
But for now, our package named EECS2030 serves our purposes adequately.
Now if you look in the Package Explorer, our EECS2030 package is under Tutorial ->
src -> EECS2030. src is the source folder. Hence, when it comes time to submit your
files and you want to locate your source file, it will be in
workspace->Project->src->package->file. So in our case, it would be:
EECS2030->Tutorial->src->EECS2030->HelloWorld.java
Now, to finally create our HelloWorld.java, we must create a class.
You can do this by right-clicking the package, then clicking New, and then Class.
You will see this window. Enter the name of your class, in this case HellloWorld, and check the public static void main(String[]args) box - this will create the main method in your class for you. Our simple program does not inherit from any other program, so the other two boxes don't really matter.
You should now see something like this:
The TODO comment is unnecessary, so you can delete it, and the '/***@param args*/'
is starting the javadoc documentation for you.
Type in System.out.print("Hello World"); into the main body and then save your program by pressing ctrl+s on your keyboard.
Now you can run your program by either clicking the green run button on the toolbar, or by right-clicking your package in the package explorer and selecting Run As...->Java Application
Now your output will display in the console at the bottom!
Now, if you want to submit this file, open up a console. By default, you will be in your
home directory (/cse/home/##### - where ##### is your EECS user name). Recall that
we created our workspace, called EECS030 in the home directory. We first go into
our workspace directory by typing cd EECS030
Now, if you type ls, you will see the contents of your workspace, which, for now, consists of
the project we created named Tutorial.
Go into the Tutorial directory by typing cd Tutorial.
Type ls to list the contents of the directory. You should see
two directories named bin and src. The directory named
src is where your Java source code files are located.
Go into the src directory by typing cd src.
Type ls to list the contents of the directory. You should see
one directory named EECS2030 which is the name of the package
that we created.
Go into the EECS2030 directory by typing cd EECS2030.
Type ls to list the contents of the directory. You should see
one file named HelloWorld.java which is the name of the Java
class that we created.
Finally, to submit your Java file you use the submit command:
submit 2030 lab0 HelloWorld.java
This electronically submits the file named HelloWorld.java to
the course 2030 for the assignment named lab0. Make sure
that you see the message All files successfully submitted otherwise
something has gone wrong.