Debian Linux Install Eclipse Java / C / C++ IDE

How do I install Java and C/C++ integrated development environment called Eclipse under Debian GNU/Linux squeeze v6.xx/7.xx/8.xx/9.xx?

Eclipse is a multi-language software development environment. It is written mostly in Java. It can be used to develop applications in Java and, other programming languages including Ada, C, C++, and much more.
Tutorial details
Difficulty level Intermediate
Root privileges Yes
Requirements Debian/Ubuntu
Est. reading time 5m
Development environments include the Eclipse Java development tools (JDT) for Java and Scala, Eclipse CDT for C/C++ and Eclipse PDT for PHP, among others. You need to install the following packages:
  • sun-java6-jdk and sun-java6-jre (or default-jdk and default-jre) – Sun Java SDK and runtime environment.
  • eclipse-jdt – Eclipse Java development tools (JDT).
  • eclipse-cdt – C/C++ development tools for Eclipse IDE.
  • eclipse – Extensible tool platform and Java IDE.
  • gcc c and c++GNU/c and c++ compiler collection.

The following instructions are only compatible with Debian version 6/7/8 and 9.

Sun JDK installation

Open a terminal and login as a root user using sudo -s or su - command. Type the following apt-get command to install Sun JAVA SDK on Debian 6.xx:
$ sudo apt-get install sun-java6-jdk sun-java6-jre sun-java6-bin
Type the following command to configure and set Sun JDK as default java:
$ sudo update-java-alternatives -s java-6-sun
Or use the following command:
$ sudo update-alternatives --config java
Sample outputs:

Fig.01: Setting the default Java to use to Sun Java 6

For Debian version 7/8/9 run:

$ sudo apt-get install default-jdk jre
Verify your new settings, enter:
$ java -version
Sample outputs:

java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

Adjust path as per your java version.

Type the following commands to set up JAVA_HOME and PATH variables for your setup:

echo 'export JAVA_HOME=/usr/lib/jvm/java-6-sun' >> ~/.bash_profile
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> ~/.bash_profile
## set the shell vars ##
. ~/.bash_profile

Eclipse IDE installation

Open a terminal and login as a root user using sudo -s or su - command. Type the following command to install Eclipse IDE for Java and C/C++:
$ sudo sudo apt-get install eclipse eclipse-jdt eclipse-cdt
Sample outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  ant ant-optional eclipse-pde eclipse-platform eclipse-platform-data
  eclipse-plugin-cvs eclipse-rcp exuberant-ctags fastjar jarwrapper junit
  junit4 libasm3-java libcommons-beanutils-java libcommons-codec-java
  libcommons-collections3-java libcommons-compress-java
  libcommons-digester-java libcommons-el-java libcommons-httpclient-java
  libcommons-logging-java libdb-je-java libdb4.7-java libdb4.7-java-gcj
  libecj-java libequinox-osgi-java libhamcrest-java libicu4j-java
  libjasper-java libjaxp1.3-java libjaxp1.3-java-gcj libjetty-java
  libjline-java libjsch-java libjtidy-java liblucene2-java libregexp-java
  libservlet2.4-java libservlet2.5-java libslf4j-java libxerces2-java
  libxerces2-java-gcj sat4j xulrunner-1.9.1
Suggested packages:
  ant-gcj ant-doc libbsf-java liboro-java libxalan2-java liblog4j1.2-java
  jython antlr libbcel-java libjdepend-java libxml-commons-resolver1.1-java
  libcommons-net-java javacc ant-optional-gcj junit-doc
  libcommons-beanutils-java-doc libcommons-collections3-java-doc
  libcommons-digester-java-doc libcommons-httpclient-java-doc
  libexcalibur-logkit-java libavalon-framework-java
  libcommons-logging-java-doc ecj libecj-java-gcj jetty libjetty-java-doc
  libjline-java-doc libjtidy-java-doc libservlet2.4-java-gcj libjavassist-java
  libxerces2-java-doc
The following NEW packages will be installed:
  ant ant-optional eclipse eclipse-cdt eclipse-jdt eclipse-pde
  eclipse-platform eclipse-platform-data eclipse-plugin-cvs eclipse-rcp
  exuberant-ctags fastjar jarwrapper junit junit4 libasm3-java
  libcommons-beanutils-java libcommons-codec-java libcommons-collections3-java
  libcommons-compress-java libcommons-digester-java libcommons-el-java
  libcommons-httpclient-java libcommons-logging-java libdb-je-java
  libdb4.7-java libdb4.7-java-gcj libecj-java libequinox-osgi-java
  libhamcrest-java libicu4j-java libjasper-java libjaxp1.3-java
  libjaxp1.3-java-gcj libjetty-java libjline-java libjsch-java libjtidy-java
  liblucene2-java libregexp-java libservlet2.4-java libservlet2.5-java
  libslf4j-java libxerces2-java libxerces2-java-gcj sat4j xulrunner-1.9.1
0 upgraded, 47 newly installed, 0 to remove and 8 not upgraded.
Need to get 148 MB/221 MB of archives.
After this operation, 284 MB of additional disk space will be used.
Do you want to continue [Y/n]? y

Use Eclipse IDE

Type the following command
$ eclipse &
Or visit the following Gnome menu options:
Applications > Programming > eclipse

Putting it all together: HelloWorld

First, you need to choose a workspace folder:

Fig.02: Choose a workspace folder

Next, you will see the default splash and welcome screen as follows:

Fig.03: Welcome to Eclipse

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

Fig.04: Creating a new java project

Set project name to HelloWorld and click on the Next > Finish button:

Fig.05: Setting the project name

You need to create a new class called HelloWorld with main(). Click on the File > New Class > Set class name to HelloWorld > make sure you select the checkbox public static void main(String[] args) to create the main() method > click the Finish button:

Fig.06: Adding a new class

Add the following code inside main() method:

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

Save the file by pressing CTRL-s. To run your program just click the Run HelloWorld button:

Fig.07: Running the HelloWorld Java app

This faq and sample JAVA app concludes brief walkthrough of the new Eclipse JAVA IDE installation and configuration under Debian GNU/Linux operating systems.

A note about creating c/c++ project

First, make sure GNU/gcc c and c++ compiler collection is installed and working for your setup. To create a c or c++ project – visit File > Project > Select either c or c++ > click the Next button:

Fig.08: Creating a new c/c++ project

Set the project name to HelloWorldCPP > Select Empty project > Click the Finish button

Fig.09: Set C/C++ project name

Add a new src file called HelloWorld by visiting File > New > Source file > Set source file name to HelloWorldCPP.cpp > click the Finish button:

Fig.10: Adding a new C++ file

Add the following sample C++ code

//============================================================================
// Name        : HelloWorldCPP.cpp
// Author      : nixCraft
// Version     :
// Copyright   : Copyleft
// Description : Hello World in C++, Ansi-style
//============================================================================
 
#include <iostream>
using namespace std;
 
int main() {
	cout << "!!!Hello World!!!" << endl;
	return 0;
}

Save the program. To run click on the run “HelloworldCPP” button:

Fig.11: Running HelloWorldCPP C++ program

The sample C++ app concludes brief walkthrough of the new Eclipse C/C++ IDE installation and configuration under Debian GNU/Linux operating systems.

See also

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

🐧 6 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
6 comments… add one
  • Nikola Feb 22, 2014 @ 21:25

    Awesome!

  • nirag Jul 25, 2014 @ 4:54

    if i want to install offline so i can do this

  • Mounir Oct 18, 2014 @ 22:51

    Hi !
    Thanks for this tutorial you saved my day from a big headache :)

  • Mixa Dec 12, 2014 @ 11:59

    Respect. simple and useful…

  • gnan Jan 21, 2015 @ 9:31

    thank u……than u…..soooooooooooooooooo much

  • Jorge Jun 30, 2015 @ 15:12

    Muito bom. Obrigado

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