Q. How do I install Eclipse integrated development environment and write first program under Ubuntu Linux Eclipse IDE?

A. Eclipse is free and open source integrated development environment (IDE) software. You need to install Java JDK and JRE before installing Eclipse.

Install Sun JDK and JRE

Open terminal and type the following commands to install Sun Java JDK and JRE:
$ sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
$ sudo vi /etc/jvm

Add following line at the top:
Set up environment:
$ echo 'export JAVA_HOME=/usr/lib/jvm/java-6-sun' >> ~/.bash_profile
$ echo 'export PATH=$PATH:$JAVA_HOME/bin' >> ~/.bash_profile
$ . ~/.bash_profile

Make sure you see correct JAVA version:
$ java -version
Sample output:

java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Server VM (build 10.0-b22, mixed mode)

Install Eclipse

Type the following command to install extensible Tool Platform, Java IDE, Java Development Tools plug-ins for Eclipse:
$ sudo apt-get install eclipse eclipse-jdt

How do I start eclipse?

Click on Applications > Programming > Eclipse

OR type the following command at shell prompt:
$ eclipse &
You should see an eclipse splash screen followed by workspace launcher:

Fig.01: Eclipse IDE workspace Launcher

Your first java program using Eclipse

Click Ok to load IDE. Close welcome screen. Click on Windows > Open perspective > Select Java .

Step # 1: Create a project

You need to create a project to put all .java and related project files. Click on File > New > Project > Select Java Project

Fig.01: Creating first java project

Click Next > Type Project name “HelloWorld” > Click on Finish:

Fig.02: HelloWorld Project

Step # 3: Create a new class

Now you need add a new class called HelloWorld. Click on File > New > Class > Set class name to “HelloWorld” > Select the checkbox to create the main() method > click Finish button:

Fig.03: Adding your first class called HelloWorld

Step # 3: Type the code

Type the following code inside main() method:

System.out.println("Hello world!\n");

Fig.04: Your first java program using Eclipse Java IDE

Press CTRL + S to save program (or visit File > Save option).

Step # 4: Run your first java application

To run your program Select HelloWorld.java from left panel. Click on Run > Run As > Java Application :

Fig.05: Java program output at the bottom of IDE

The Console view should appear at the bottom of the IDE to display the “Hello, world!” output.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 15 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
15 comments… add one
  • Max Oct 10, 2008 @ 17:34

    I’ve always use the following to change default java versions:

    update-java-alternatives –list

    sudo update-java-alternatives –set

    source: http://bit.ly/3Oa2uF

  • albert Apr 15, 2009 @ 11:06

    this is great! im new in ubuntu but it has a lot of kind hearted people that shares their knowledge…. hope i can contribute soon….

    keep up the good work guyz…

  • george May 19, 2009 @ 0:18

    1) May I know what is this for :
    $ sudo vi /etc/jvm
    Add following line at the top:

    I don’t have the jvm file under /etc/.
    2) After starting my ecilipse, I tried to create a class, but all contents below the question “Which method stub Would you like to create”in the graphic dialog is gone. I can’t select one method stub.
    3) After setting the PATH variable, I can start eclipse from anywhere, but if I click on the eclipse.exe on the file browser, an error message will show reading “Can’t find Java Virtual Machine…..”
    My eclipse is v 3.4.2 Ganymede
    Java jdk is jdk1.6.0_13

    Your help is much appreciated!

    • 🐧 nixCraft May 19, 2009 @ 0:45

      You need to use latest sun-java6-jdk package. Did you installed sun-java6-jdk?

  • george May 19, 2009 @ 3:48

    Yes I did.

  • wenbo Aug 5, 2009 @ 8:58

    does this eclipse can be dev web app?

  • Kvex Oct 13, 2009 @ 8:03

    Thanks for that. It realy helps me.

  • ajay Mar 10, 2010 @ 1:04

    Thank you!! this was useful.

  • lokesh Jun 19, 2010 @ 1:02

    thanks.it was useful

  • Anonymous Jul 5, 2010 @ 14:45


  • Stoic Jan 10, 2011 @ 17:13


  • saad Jun 21, 2011 @ 6:35

    how to install birt in eclipse for
    linux ubuntu

  • deodiaus Apr 5, 2012 @ 21:35

    I have followed most of your suggestions.
    I have Eclipse 3.5.2 installed as myself on Ubantou linkx 2.6.32-40
    I don’t have a ~/.bash_profile but put that in ~/.profile
    I don’t seem to have a Java profile. How do I enable that?

  • Prabu Jun 17, 2012 @ 7:47

    Was very helpful.. Thanks a lot.

  • Ramnath Oct 2, 2012 @ 3:40

    Thanks dude, this really helped :-)

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum