Difference between revisions of "Install Eclipse"
(→Testing Eclipse for the First Time) |
|||
Line 57: | Line 57: | ||
After you've installed Eclipse following one of the procedures above, open Eclipse. | After you've installed Eclipse following one of the procedures above, open Eclipse. | ||
− | Choose File.. | + | Choose File..New..Java Project. |
[[File:EclipseOpenNewProject1.png|center]] | [[File:EclipseOpenNewProject1.png|center]] | ||
− | Enter name of project in Project name field and click Finish. | + | Enter "HelloWorld" as the name of project in Project name field and click Finish. |
[[File:EclipseOpenNewProject2.png|center]] | [[File:EclipseOpenNewProject2.png|center]] | ||
− | Choose File..New..Class. Enter name of class in the Name field (HelloWorldApp). Click Finish. | + | Choose File..New..Class. Enter "HelloWorldApp" as the name of class in the Name field (HelloWorldApp). Click Finish. |
[[File:EclipseOpenNewClassFile.png|center]] | [[File:EclipseOpenNewClassFile.png|center]] | ||
− | Enter the following code in tabbed window: | + | A tab named "HelloWorldApp.java" should appear in the big central window. Enter the following code in tabbed window: |
− | + | <pre> | |
+ | public class HelloWorldApp { | ||
/** | /** | ||
* The HelloWorldApp class implements an application that | * The HelloWorldApp class implements an application that | ||
Line 78: | Line 79: | ||
*/ | */ | ||
public static void main(String[] args) { | public static void main(String[] args) { | ||
− | + | System.out.println("Hello World!"); // Display the string. | |
− | + | } | |
− | + | } | |
+ | </pre> | ||
Line 86: | Line 88: | ||
− | Click Run button (green circle with white triangle). | + | Click Run button (green circle with white triangle). This is usually found in the bar of buttons near the top. |
[[File:EclipseRunButton.png|center]] | [[File:EclipseRunButton.png|center]] | ||
− | Program output will appear in Console tab | + | Program output will appear in Console tab. The Console is usually on the bottom. The output should say "Hello World!" It's alive! |
[[File:EclipseResultHelloWorld.png|center]] | [[File:EclipseResultHelloWorld.png|center]] | ||
See also: http://docs.oracle.com/javase/tutorial/getStarted/application/index.html | See also: http://docs.oracle.com/javase/tutorial/getStarted/application/index.html |
Revision as of 12:01, 24 September 2012
The following article explains how to install Eclipse on your computer. The guide is targeted to students of the Java Programming course available on Art of Problem Solving. The version that we will be using is: Eclipse IDE for Java Developers, version 4.2.
Since the installation is system-specific for Mac, Windows, and Linux, read and follow the instructions for the system that you have installed.
Linux/Ubuntu
Check if your system is 32- or 64-bit. You can accomplish this by opening Terminal, and typing:
$ uname -m
If you get back: x86_64, then you have a 64-bit system, otherwise, you have 32-bit system.
Go to: Ubuntu Downloads. On the third line from the top, that says: Eclipse IDE for Java Developers, click the Linux 32 Bit or Linux 64 Bit link on the right, depending on the type of your system.
Download the relevant distribution of Eclipse (i.e. the tar.gz source file, which is an archive that contains the source code for eclipse).
The next step is to extract the tar.gz source file. Open Terminal and navigate to the location where the tar.gz file was saved. Then, run:
$ tar xzf --name of file--
such as:
$ tar xzf eclipse-java-juno-linux-gtk.tar.gz
Next, move the created eclipse executable to the /opt/ system folder. After entering the following command into Terminal, you need to enter the root password.
$ sudo mv eclipse /opt/
Now navigate to the /opt/ folder if you are not there already. Change the permissions on the eclipse executable:
$ sudo chown -R root:root eclipse & sudo chmod -R +r eclipse
Create an executable in your path, and open the text editor Nano:
$ sudo touch /usr/bin/eclipse & sudo chmod 755 /usr/bin/eclipse &sudo nano /usr/bin/eclipse
Now enter the following text into Nano:
$ #!/bin/sh $ #export MOZILLA_FIVE_HOME="/usr/lib/mozilla/" $ export ECLIPSE_HOME="/opt/eclipse" $ $ECLIPSE_HOME/eclipse $*
Save your work (CTRL+o) and close Nano (CTRL+x).
Now run Eclipse for the first time:
$ /opt/eclipse/eclipse -clean &
(every next time you run Eclipse, just enter eclipse in Terminal):
$ eclipse
Note: If you get an error about Java not installed, make you have Java Virtual Machine installed. You can do this by either installing OpenJDK Java 7 Runtime from the Ubuntu Software Center, or running the following command in Terminal:
$ sudo apt-get install openjdk-7-jre
See also: http://colinrrobinson.com/technology/install-eclipse-ubuntu/
Testing Eclipse for the First Time
After you've installed Eclipse following one of the procedures above, open Eclipse.
Choose File..New..Java Project.
Enter "HelloWorld" as the name of project in Project name field and click Finish.
Choose File..New..Class. Enter "HelloWorldApp" as the name of class in the Name field (HelloWorldApp). Click Finish.
A tab named "HelloWorldApp.java" should appear in the big central window. Enter the following code in tabbed window:
public class HelloWorldApp { /** * The HelloWorldApp class implements an application that * simply prints "Hello World!" to standard output. */ public static void main(String[] args) { System.out.println("Hello World!"); // Display the string. } }
Click Run button (green circle with white triangle). This is usually found in the bar of buttons near the top.
Program output will appear in Console tab. The Console is usually on the bottom. The output should say "Hello World!" It's alive!
See also: http://docs.oracle.com/javase/tutorial/getStarted/application/index.html