Difference between revisions of "Install Eclipse"

(Testing Eclipse for the First Time)
(Updated Eclipse and Java version information.)
 
(40 intermediate revisions by 3 users not shown)
Line 1: Line 1:
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.  
+
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, Luna (4.4.1), for Java (8).  
  
Since the installation is system-specific for Mac, Windows, and Ubuntu, read and follow the instructions for the system that you have installed.
+
Since the installation is system-specific for Mac, Windows, and Linux, read and follow the instructions for the system that you have installed.
 +
 
 +
Note that, first, you need to make sure you have a version of JVM(Java Virtual Machine) installed. See [[Install Java]] page for instructions.
 +
 
 +
=Windows=
 +
 
 +
1) '''Check if your system is 32- or 64-bit.'''  You can find this in the Control Panel.  In Windows 7, click on the System and Security link:
 +
 
 +
[[File:ControlPanel.png|center]]
 +
 
 +
Then click on the System link:
 +
 
 +
[[File:SystemAndSecurity.png|center]]
 +
 
 +
You can read if you have a 32- or 64-bit system under System Type:
 +
 
 +
[[File:System.png|center]]
 +
 
 +
2) '''Download the Eclipse IDE for Java Developers.'''  Go to [http://www.eclipse.org/downloads Eclipse downloads].  Do '''not''' select Eclipse for Java EE Developers, but Eclipse for Java Developers.  Click on the 32- or 64-bit link to the right appropriate for your system.
 +
 
 +
[[File:EclipseDownload.png|center]]
 +
 
 +
This move you to a new page.  Click the green download button.  If you get a dialog box, select Save File and then click OK.
 +
 
 +
[[File:EclipseMirror.png|center]]
 +
 
 +
3) '''Extract Eclipse.'''  Go to your download directory.  Right click on the download and select Extract All...
 +
 
 +
[[File:Downloads.png|center]]
 +
 
 +
When the dialog box appears, choose where you would like Eclipse to install.  We suggest a short path, such as, "C:\eclipse".  Then click Extract.
 +
 
 +
4) '''Run Eclipse.'''  Go to your installation directory and double click on the Eclipse.exe application to run it.  Each time you run Eclipse, it will ask you for a workspace for this session.  The workspace is a directory where your work will be stored.  To continue projects from earlier sessions, you should enter the same workspace that you used previously.  If you wish to use the default workspace, click OK.  After this, continue with [[#Testing Eclipse for the First Time|Testing Eclipse for the First Time]] below.
 +
 
 +
[[File:Workspace.png|center]]
 +
 
 +
=Mac=
 +
 
 +
All modern Macs are 64-bit.  If you want to be sure, open a Terminal window (click on the Applications menu, then the Utilities subfolder, then the Terminal app), and type "uname -m" at the prompt.  If it returns something like "x86_64", you have a 64-bit Mac.  (However, on Mac OS X 10.8 (Mountain Lion), installing the 64-bit version might not work.  If you get a mysterious error, try installing the 32-bit version.  It won't make any difference for the class if you have the 32-bit or 64-bit version installed.)
 +
 
 +
Go the [http://www.eclipse.org/downloads Eclipse download page].  Click on the "Mac OS X 64 Bit" link in the "Eclipse IDE for Java Developers" row:
 +
 
 +
[[File:MacEclipseDownloads.png|center]]
 +
 
 +
On the next page, click on the giant green arrow:
 +
 
 +
[[File:MacEclipseGiantArrow.png|center]]
 +
 
 +
After the file downloads, go to your Downloads folder.  There should be a file called "eclipse-java-juno-macosx-cocoa-x86_64.tar.gz".  Double-click on it.  It will then self-extract and create a folder called "eclipse".  Drag this folder to your Applications folder.  Then click on the "Eclipse" icon inside the folder:
 +
 
 +
[[File:MacEclipseIcon.png|center]]
 +
 
 +
This will start Eclipse.  If you are using Mac OS X 10.8 (Mountain Lion), you may get a security warning, and if so you'll have to open it manually the first time: open a Finder window, and navigate to the Applications -> eclipse folder.  Then hold down Control while you click on the Eclipse icon.  You'll be prompted to verify that you want to open Eclipse: click "OK" in the box that pops up.
 +
 
 +
Each time you run Eclipse, it will ask you for a workspace for this session.  The workspace is a directory where your work will be stored.  To continue projects from earlier sessions, you should enter the same workspace that you used previously.  If you wish to use the default workspace (which we recommend), just click OK.  After this, continue with [[#Testing Eclipse for the First Time|Testing Eclipse for the First Time]] below.
  
 
=Linux/Ubuntu=
 
=Linux/Ubuntu=
Line 57: Line 111:
 
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..New…Java Project.
+
Choose File..New..Java Project.
  
Enter name of project in [i]Project name:[/i] field; click Finish
+
[[File:EclipseOpenNewProject1.png|center]]
  
Choose File..New..Class.
+
Enter "HelloWorld" as the name of project in Project name field and click Finish.
  
Enter name of class in [i]Name:[/i] field (HelloWorldApp); click Finish
+
[[File:EclipseOpenNewProject2.png|center]]
  
Enter the following code in tabbed window:
 
  
 +
Choose File..New..Class. Enter "HelloWorldApp" as the name of class in the Name field (HelloWorldApp). Click Finish.
 +
 +
[[File:EclipseOpenNewClassFile.png|center]]
 +
 +
 +
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
    * simply prints "Hello World!" to standard output.
+
    * simply prints "Hello World!" to standard output.
    */
+
    */
     class HelloWorldApp {
+
     public static void main(String[] args) {
        public static void main(String[] args) {
+
        System.out.println("Hello World!"); // Display the string.
            System.out.println("Hello World!"); // Display the string.
 
        }
 
 
     }
 
     }
 +
}
 +
</pre>
 +
 +
 +
[[File:EclipseEnterCode.png|center]]
 +
 +
 +
Click Run button (green circle with white triangle).  This is usually found in the bar of buttons near the top.
 +
[[File:EclipseRunButton.png|center]]
  
  
 +
Program output will appear in Console tab.  The Console is usually on the bottom.  The output should say "Hello World!"  It's alive!
  
Click Run button (green circle with white triangle) or choose Run…Run.
+
[[File:EclipseResultHelloWorld.png|center]]
  
Program output will appear in Console tab
+
See also: http://docs.oracle.com/javase/tutorial/getStarted/application/index.html

Latest revision as of 16:47, 9 October 2014

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, Luna (4.4.1), for Java (8).

Since the installation is system-specific for Mac, Windows, and Linux, read and follow the instructions for the system that you have installed.

Note that, first, you need to make sure you have a version of JVM(Java Virtual Machine) installed. See Install Java page for instructions.

Windows

1) Check if your system is 32- or 64-bit. You can find this in the Control Panel. In Windows 7, click on the System and Security link:

ControlPanel.png

Then click on the System link:

SystemAndSecurity.png

You can read if you have a 32- or 64-bit system under System Type:

System.png

2) Download the Eclipse IDE for Java Developers. Go to Eclipse downloads. Do not select Eclipse for Java EE Developers, but Eclipse for Java Developers. Click on the 32- or 64-bit link to the right appropriate for your system.

EclipseDownload.png

This move you to a new page. Click the green download button. If you get a dialog box, select Save File and then click OK.

EclipseMirror.png

3) Extract Eclipse. Go to your download directory. Right click on the download and select Extract All...

Downloads.png

When the dialog box appears, choose where you would like Eclipse to install. We suggest a short path, such as, "C:\eclipse". Then click Extract.

4) Run Eclipse. Go to your installation directory and double click on the Eclipse.exe application to run it. Each time you run Eclipse, it will ask you for a workspace for this session. The workspace is a directory where your work will be stored. To continue projects from earlier sessions, you should enter the same workspace that you used previously. If you wish to use the default workspace, click OK. After this, continue with Testing Eclipse for the First Time below.

Workspace.png

Mac

All modern Macs are 64-bit. If you want to be sure, open a Terminal window (click on the Applications menu, then the Utilities subfolder, then the Terminal app), and type "uname -m" at the prompt. If it returns something like "x86_64", you have a 64-bit Mac. (However, on Mac OS X 10.8 (Mountain Lion), installing the 64-bit version might not work. If you get a mysterious error, try installing the 32-bit version. It won't make any difference for the class if you have the 32-bit or 64-bit version installed.)

Go the Eclipse download page. Click on the "Mac OS X 64 Bit" link in the "Eclipse IDE for Java Developers" row:

MacEclipseDownloads.png

On the next page, click on the giant green arrow:

MacEclipseGiantArrow.png

After the file downloads, go to your Downloads folder. There should be a file called "eclipse-java-juno-macosx-cocoa-x86_64.tar.gz". Double-click on it. It will then self-extract and create a folder called "eclipse". Drag this folder to your Applications folder. Then click on the "Eclipse" icon inside the folder:

MacEclipseIcon.png

This will start Eclipse. If you are using Mac OS X 10.8 (Mountain Lion), you may get a security warning, and if so you'll have to open it manually the first time: open a Finder window, and navigate to the Applications -> eclipse folder. Then hold down Control while you click on the Eclipse icon. You'll be prompted to verify that you want to open Eclipse: click "OK" in the box that pops up.

Each time you run Eclipse, it will ask you for a workspace for this session. The workspace is a directory where your work will be stored. To continue projects from earlier sessions, you should enter the same workspace that you used previously. If you wish to use the default workspace (which we recommend), just click OK. After this, continue with Testing Eclipse for the First Time below.

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.

JavaSelection.png


Download the relevant distribution of Eclipse (i.e. the tar.gz source file, which is an archive that contains the source code for eclipse).

DownloadEclipseSelectMirror.png

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.

EclipseOpenNewProject1.png

Enter "HelloWorld" as the name of project in Project name field and click Finish.

EclipseOpenNewProject2.png


Choose File..New..Class. Enter "HelloWorldApp" as the name of class in the Name field (HelloWorldApp). Click Finish.

EclipseOpenNewClassFile.png


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.
    }
}


EclipseEnterCode.png


Click Run button (green circle with white triangle). This is usually found in the bar of buttons near the top.

EclipseRunButton.png


Program output will appear in Console tab. The Console is usually on the bottom. The output should say "Hello World!" It's alive!

EclipseResultHelloWorld.png

See also: http://docs.oracle.com/javase/tutorial/getStarted/application/index.html