Install and use Eclipse for Linux on POWER

Get started writing C/C++ and Java applications on Red Hat and SUSE

Eclipse is an open source community that provides a development platform and a collection of application frameworks for building software. Learn how to install and use Eclipse specifically for Linux® running on IBM® POWER™ processor-based systems. Learn, also, how to use Eclipse to compile and run applications through sample Java™ and C programs.

Calvin Sze (calvins@us.ibm.com), Linux consultant , IBM, Software Group

Calvin Sze is a Linux consultant for the IBM eServer Solutions Enablement organization at IBM, based in Austin, TX. Calvin’s main role is to help solution developers bring their applications to Linux on POWER. Calvin has been involved in software development and system integration on both Linux and AIX platforms for more than 10 years. You can contact Calvin at calvins@us.ibm.com.



05 May 2006

Also available in Russian Japanese

Introduction

Eclipse is an extensible, open source IDE (integrated development environment). It is completely platform and language neutral. In addition to the eclectic mix of languages supported by the Eclipse Consortium (Java, C/C++, Cobol), there are also projects underway to add support to Eclipse for languages as diverse as Python, Eiffel, PHP, Ruby, and C#. As the installation process of the required tools is somewhat tricky, this articles describes, step by step, how to install and configure a stable development environment using the Eclipse Workbench on Linux running on IBM pSeries™.

All work at Eclipse is done in sub-projects and components organized under top-level projects. The Eclipse Project is structured into the projects shown in Figure 1:

Figure 1. Eclipse top-level projects
Eclipse top-level projects

Table 1 describes the three Eclipse top-level projects:

Table 1. Descriptions of the Eclipse top-level projects
ProjectsDescription
PlatformThe platform upon which all other Eclipse-based tools are built
JDTThe Java development tooling, or Java IDE
PDEPlug-in development environment

Table 2 lists the sub-projects of the Platform project:

Table 2. Components of the Platform project
Sub-projectsDescription
AntAnt Java-based build tool
CompareUniversal compare facility
CoreCore libraries
DebugUniversal debugger
DocDocumentation
HelpHelp system
RelengRelease engineering
ScriptingScripting support
SearchIntegrated search facility
SWTStandard Widget Toolkit
TextText editor framework
UIUser interface libraries
UpdateDynamic update/install/field service
VCMVersioning and configuration management
WebDAVWebDAV integration

Table 3 lists the sub-projects of the JDT project.

Table 3. Components of the JDT project
Sub-projectsDescription
JDT CoreCompiler and Builder
JDT DocDocumentation
JDT UIJava IDE user interface
JDT DebugDebug support for Java
CDTC/C++ compiler and builder

Table 4 lists the sub-projects of the PDE project.

Table 4. Components of the PDE project
Sub-ProjectsDescription
PDE buildPDE build
PDE DocDocumentation
PDE UIPDE user interface

To introduce the usage of Eclipse, this article demonstrates how to develop simple Java and C/C++ projects as a starting point.


Installing Eclipse

This section shows the procedures for downloading Eclipse, installing its prerequisites, and installing Eclipse itself. There are two supported Linux distributions on IBM pSeries, SUSE Linux Enterprise Server (SLES), and Red Hat Enterprise Linux Advance Server (RHEL AS or RHEL). There are some small differences in the Eclipse installation procedure between these two versions. The distributions used here are SLES, Version 9, Service Pack 3 (SLES9 SP3) and RHEL, Version 4, Update 3 (RHEL4 U3).

Before downloading and using Eclipse, read and agree to the Eclipse user agreement. Now you can download the Eclipse program.

From your Web browser, go to eclipse.org, and click on the download tag. You will see a Web page similar to the one shown in Figure 2:

Figure 2. Download page for Eclipse SDK package
Download page for Eclipse SDK package

Click on Eclipse SDK 3.1.2, and a page with download sites is presented to you. Choose a site physically nearest to you, and choose a directory in which to save the SDK, such as /tmp.

The download page automatically recognizes the platform to which you are downloading; you are downloading the Linux on POWER binary if your Web browser is running on a Linux on POWER machine. If you decide to download the Eclipse application to your Windows workstation and then copy it to a Linux on POWER machine, please note that you are downloading the Windows version by default. To select the Linux on POWER version manually, click on Other downloads for 3.1.2, and then select Linux (PPC/GTK2).

Installing prerequisites

On a machine with SLES9 SP3 installed, two packages are required for Java development -- IBMJava2-JRE-1.4.2-0.55.ppc and IBMJava2-SDK-1.4.2-0.55.ppc. They are not automatically installed by the default Linux OS installation. These two packages are in SLES9 SP3 CD #2.

Use the rpm utility to install these two packages:

# rpm -Uvh IBMJava2-JRE-1.4.2-0.55.ppc.rpm
# rpm -Uvh IBMJava2-SDK-1.4.2-0.55.ppc.rpm

For C/C++ development in SLES9 SP3, gcc and gcc-c++ rpms must be installed. They require three packages -- glibc-devel-2.3.3-98.61.ppc.rpm and cpp-3.3.3-43.41.ppc.rpm, which can be can found on SLES9 SP3 CD #1, and libstdc++-devel-3.3.3-43.24.ppc.rpm on SLES9 CORE CD #2. To install these packages, use the following commands:

# rpm -Uvh glibc-devel-2.3.3-98.61.ppc.rpm
# rpm -Uvh cpp-3.3.3-43.41.ppc.rpm
# rpm -Uvh libstdc++-devel-3.3.3-43.24.ppc.rpm

Now, you can install gcc and gcc-c++ in SLES 9 SP3. You will find their rpm packages on SLES9 SP3 CD #1. Install these packages like so:

rpm -Uvh libstdc++-devel-3.3.3-43.24.ppc.rpm
rpm -Uvh libstdc++-devel-3.3.3-43.24.ppc.rpm

For a machine with RHEL4 U3 installed, there are also two packages required for Java development -- compat-libstdc++-33-3.2.3-47.3.ppc, which can be found on RHEL4 U3 CD #3, and java-1.4.2-ibm-1.4.2.3-1jpp_14rh.ppc, which is on Application CD #1.

Use the following commands to install these two packages:

# rpm -Uvh compat-libstdc++-33-3.2.3-47.3.ppc.rpm
# rpm -Uvh java-1.4.2-ibm-1.4.2.3-1jpp_14rh.ppc.rpm

For C/C++ development in RHEL4, the gcc and gcc-c++ rpms require four packages -- glibc-kernheaders-2.4-9.1.98.EL.ppc.rpm, glibc-headers-2.3.4-2.19.ppc.rpm, glibc-devel-2.3.4-2.19.ppc.rpm, and libstdc++-devel-3.4.5-2.ppc.rpm. You will find all of these on RHEL 4 U3 CD #3. To install them, use the following commands:

# rpm -Uvh glibc-kernheaders-2.4-9.1.98.EL.ppc.rpm
# rpm -Uvh glibc-headers-2.3.4-2.19.ppc.rpm
# rpm -Uvh glibc-devel-2.3.4-2.19.ppc.rpm
# rpm –Uvh libstdc++-devel-3.4.5-2.ppc.rpm

Now, you can install gcc and gcc-c++. Their rpm packages are also on RHEL4 U3 CD #3. Install them using the following commands:

rpm -Uvh gcc-3.4.5-2.ppc.rpm
rpm -Uvh gcc-c++-3.4.5-2.ppc.rpm

Installing Eclipse

The procedures to install Eclipse itself are the same on both SLES9 SP3 and RHEL4 U3:

# cd /opt
/opt # tar -zxvf /tmp/eclipse-SDK-3.1.2-linux-gtk-ppc.tar.gz

Using Eclipse for Java development

This section demonstrates how a simple Java program can be developed in Eclipse. For more information on the features of the Eclipse SDK, please refer to the Help utility built in Eclipse.

  1. Run the following command to start Eclipse:

    /opt/eclipse/eclipse
  2. Enter a directory where you want to store your projects. In Figure 3, /opt/eclipse/workspace is the directory:

    Figure 3. Selecting the Eclipse workspace
    Selecting the Eclipse workspace
  3. You are presented with the Eclipse welcome page, as shown in Figure 4. On the menu bar, select File, New, and then Project.

    Figure 4. Eclipse welcome page
    Eclipse welcome page
  4. The New Project window pops up, as shown in Figure 5. Click Next with Java Project selected.

    Figure 5. Creating a new Java project
    Creating a new Java project
  5. Type MInfo in the Project name field, as shown in Figure 6, and click Next.

    Figure 6. Entering your project name
    Entering your project name
  6. Click Finish in the Java Settings window, as shown in Figure 7.

    Figure 7. Accepting the default Java settings
    Accepting the default Java settings
  7. Click on the WorkBench icon in the Welcome window, and the Eclipse Java perspective comes up with Package Explorer on the left and Outline windows on the right, as shown in Figure 8.

    Figure 8. Java perspective
    Java perspective
  8. On the menu bar, select File, New, and then Class. A Java Class window pops up. Enter MInfo in the Name field, as shown in Figure 9. Click Finish.

    Figure 9. Creating a new Java class
    Creating a new Java class
  9. A MInfo.java window is created. Copy the code in Listing 1 into the window, as shown in Figure 10. The code shows the machine's architecture (ppc64), operating system (GNU/Linux), and version of the Kernel (2.6.9-34.EL).

    Listing 1. A sample Java program
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    
    public class MInfo {
       public static void main (String args[]) {
          String cmd="uname -rpo";
          String s=null;
          try {
             Process p = Runtime.getRuntime().exec(cmd, null, null);
             int i = p.waitFor();
             if (i == 0){
                BufferedReader stdInput = 
                     new BufferedReader(new InputStreamReader(p.getInputStream()));
    //               read the output from the command
                while ((s = stdInput.readLine()) != null) {
                   System.out.println(s);
                }
             }
          }
          catch (Exception e) {
             System.out.println(e);
          }
       }
    
    }
    Figure 10. Creating a sample Java program
    Creating a sample Java program
  10. From the top menu bar, select File and Save to save the Java code onto the workspace directory (/opt/eclipse/workspace as defined in step 2, above).
  11. If no syntax error is reported, with the Class MInfo highlighted in the Package Explorer on the left, select Run on the top menu bar, then select Run As, and Java Application, as shown in Figure 11.

    Figure 11. Running the Java application
    Running the Java application
  12. The program output (2.6.9-34.EL ppc64 GNU/Linux) is displayed in the console window, as shown in Figure 12.

    Figure 12. Output displayed in the console window
    Output displayed in the console window

This completes the development of a simple Java program.


Using Eclipse for C/C++ development

The C/C++ development environment for Eclipse, CDT, is not installed by default. This section introduces the steps to download and install CDT and describes the procedure to start a C/C++ project.

Install CDT

  1. From the top menu bar, select Help, Software Updates, and Find and Install, as shown in Figure 13.

    Figure 13. Start to install CDT
    Start to install CDT
  2. Select Search for new features to install in the Install/Update window, as shown Figure 14.

    Figure 14. Searching for new features to install
    Searching for new features to install
  3. Click on New Remote Site, as shown in Figure 15.

    Figure 15. Selecting a remote site
    Selecting a remote site
  4. Enter CDT3.0 in the Name field and http://download.eclipse.org/tools/cdt/releases/eclipse3.1 as the URL, as shown in Figure 16. Then click OK.

    Figure 16. Entering new remote site information
    Entering new remote site information
  5. Check the check box next to CDT3.0, and then click Finish, as shown in Figure 17.

    Figure 17. Selecting the search site
    Selecting the search site
  6. As the other mirror sites show up, highlight CDT3.0 and click OK, as shown in Figure 18.

    Figure 18. Choosing CDT3.0 among the mirror sites
    Choosing CDT3.0 among the mirror sites
  7. As the search on the site finishes, a window with all the updates available on the site appears. Check the checkboxes near Eclipse C/C++ Development Tools and Eclipse C/C++ Development Tooling SDK. Click Next, as shown in Figure 19.

    Figure 19. Selecting packages/updates
    Selecting packages/updates
  8. Read the license agreement. If you agree with it, click I accept the terms in the license agreement, as shown in Figure 20, and click Next.

    Figure 20. Read and agree to the License agreement
    Read and agree to the License agreement
  9. When the window, like that shown in Figure 21, appears, there should be two items under Features to install -- Eclipse C/C++ Development Tools 3.0.2 and Eclipse C/C++ Development Tooling SDK 3.0.2. Click Finish to start downloading components of CDT.

    Figure 21. Starting to install CDT
    Starting to install CDT
  10. When the download process finishes, click Install All in the Feature Verification window, as shown in Figure 22.

    Figure 22. Installing the Eclipse C/C++ Development Tools feature
    Installing the Eclipse C/C++ Development Tools feature
  11. When the installation finishes, click Yes to restart Eclipse, as shown in Figure 23.

    Figure 23. Prompt to restart Eclipse
    Prompt to restart Eclipse

Use Eclipse to develop a C/C++ project

  1. When Eclipse restarts, select Window, Open Perspective, and then Other, as shown in Figure 24.

    Figure 24. Opening a perspective
    Opening a perspective
  2. Highlight C/C++ and click OK, as shown in Figure 25.

    Figure 25. Selecting the C/C++ perspective
    Selecting the C/C++ perspective
  3. Close the Welcome window. The C/C++ perspective appears with the C/C++ project navigator window on the left and the Outline window on the right. From the top menu bar, select New and Project, as shown in Figure 26.

    Figure 26. Creating a new project
    Creating a new project
  4. In New Project window under the C folder, select Managed Make C Project as shown in Figure 27, then click Next. The difference between Standard Make C or C++ Project and Managed Make C or C ++ Project is as follows:
    • Standard Make C or C++ Project: You need to create a makefile or use an existing makefile in order to build your project.
    • Managed Make C or C++ Project: A managed make project generates the makefiles for you automatically.
    Figure 27. Selecting Managed Make C Project
    Selecting Managed Make C Project
  5. Enter minfo as the Project name and click Next, as shown in Figure 28.

    Figure 28. Entering the project name
    Entering the project name
  6. Select Executable (Gnu) as Project Type and click Next, as shown in Figure 29.

    Figure 29. Selecting a type of project
    Selecting a type of project
  7. Click Finish in the Additional Project Settings window, as shown in Figure 30.

    Figure 30. Additional project settings
    Additional project settings
  8. The minfo project is created in the C/C++ project navigator window on the left, as shown in Figure 31.

    Figure 31. minfo project is created
    minfo project is created
  9. From the top menu bar, select File, New, and then Source File, as shown in Figure 32.

    Figure 32. Creating a new source file
    Creating a new source file
  10. Enter minfo.c as the source file name, as shown in Figure 33, and then click Finish.

    Figure 33. Entering the source file name
    Entering the source file name
  11. A minfo.c window appears in the middle. Copy the sample C code in Listing 2 into the minfo.c window, as shown in Figure 34.

    Listing 2. A sample C program
    #include <stdio.h>
    #include <sys/utsname.h>
    
    int main (int argc, char **argv)
    {
       int i;
       struct utsname info[1];
       i=uname(info);
       if (i==0) {
          printf ("%s %s %s\n", info->release, info->machine, info->sysname);
          return 0;
       }
       else {
          printf("uanme error !\n");
          return i;
       }
    }
    Figure 34. Creating a sample C program
    Creating a sample C program
  12. From the top menu, select File and Save to save the source file. With minfo - [ppcbe] selected in the C/C++ project navigator on the left, select Run on the top menu, then select Run As and Run Local C/C++ Application, as shown in Figure 35.

    Figure 35. Running the C/C++ application
    Running the C/C++ application
  13. The output of the program, 2.6.9-34.EL ppc64 Linux, is displayed in the console window, as shown in Figure 36.

    Figure 36. Output displayed in the console window
    Output displayed in the console window

This finishes the demonstration of creating a C project.


Summary

You learned how to install the prerequisite packages for the Eclipse SDK on two Linux distributions, SLES and RHEL, running on IBM pSeries. You also saw, step by step, how to download and set up Eclipse, and how to use Eclipse to create a Java project. Finally, you learned how to install CDT, the C/C++ development environment for Eclipse, and create, compile, and execute a simple C program.

Eclipse is the most comprehensive graphical development tool available on Linux on POWER. It gives you a universal user interface to develop applications using different programming languages. Moreover, since it is widely available on other operating systems and hardware platforms, your experience of building application on Eclipse will never expire. Give it a try today!

Resources

Learn

Get products and technologies

  • With IBM trial software, available for download directly from developerWorks, build your next development project on Linux.

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Linux on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux, Open source
ArticleID=110772
ArticleTitle=Install and use Eclipse for Linux on POWER
publish-date=05052006