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

by on April 24, 2013 · 1 comment· LAST UPDATED April 24, 2013

in ,

How do I install Java and C/C++ integrated development environment called Eclipse under Debian GNU/Linux squeeze v6.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
DifficultyIntermediate (rss)
Root privilegesYes
RequirementsDebian/Ubuntu
Estimated completion timeN/A
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:

[a] sun-java6-jdk and sun-java6-jre - Sun Java SDK and runtime environment.

[b] eclipse-jdt - Eclipse Java development tools (JDT).

[c] eclipse-cdt - C/C++ development tools for Eclipse IDE.

[d] eclipse - Extensible tool platform and Java IDE.

[e] gcc c and c++ - GNU/c and c++ compiler collection.

Sun JDK installation

Open a terminal and login as a root user using sudo -s or su - command. Type the following command to install Sun JAVA SDK:
$ 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

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


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)

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

Fig.02: Choose a workspace folder

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

Fig.03: Welcome to Eclipse

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

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

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

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

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

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

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

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

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
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 1 comment… read it below or add one }

1 Nikola February 22, 2014 at 9:25 pm

Awesome!

Reply

Leave a Comment

Tagged as: , , , , , ,

Previous Faq:

Next Faq: