Eclipse IDE — Choosing it wisely
Here we gonna learn which Eclipse version choose and setup.
- Version
Go to the eclipse comparison page, and take a look on what package is best convenience for you: https://www.eclipse.org/downloads/packages/compare
Example:
- for program development: “Eclipse IDE for Java Developers”
- for developing web apps: “Eclipse IDE for Java EE Developers”
- Java : “Eclipse IDE for Java Developers” (JavaSE) or “Eclipse IDE for Java EE Developers” (JavaEE). You need to first install JDK, click here to know how.
- for PHP: “Eclipse IDE for PHP Developer”
- for C/C++: “Eclipse IDE for C/C++ Developers”
- After decide it, download that package at https://www.eclipse.org/downloads for your system — it could be available at your Linux shop store (snap / flatpak)
3. Install
Download it and extract it to /usr/bin :
wget https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2023-03/R/eclipse-jee-2023-03-R-linux-gtk-x86_64.tar.gz -P /tmp
sudo tar xf /tmp/eclipse-*.tar.gz -C /usr/local
or /opt
wget https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2023-03/R/eclipse-jee-2023-03-R-linux-gtk-x86_64.tar.gz -P /tmp
sudo tar xf /tmp/eclipse-*.tar.gz -C /opt
4. Setup
Create a symbolic link to eclipse with the command ln
adding the parameters s (symbolic) f (force) and n (no-dereference):
sudo ln -sf /usr/local/eclipse/eclipse /usr/bin/eclipse
ls -ld /usr/bin/eclipse
which eclipse
or /opt
sudo ln -sf /opt/eclipse/eclipse /usr/bin/eclipse
ls -ld /usr/bin/eclipse
which eclipse
5. Update IDE
Open eclipse with eclipse
command line and update the IDE:
Help > Check for Updates > Install Updates > Agree > Trust > Reload
6. Update tools
Make sure those tools are installed…
Help > Eclipse Marketplace… > Installed
— Essential tools for Java developer, including a Java IDE, a Git client, XML Editor, Maven and Gradle integration:
- Git integration for Eclipse
- Eclipse Java Development Tools
- Maven Integration for Eclipse
- Gradle Integration
click here to know how to install Maven.
click here to know how to install Gradle.
— Essential tools for developers working with Java and Web applications, including a Java IDE, tools for JavaScript, TypeScript, JavaServer Pages and Faces, Yaml, Markdown, Web Services, JPA and Data Tools, Maven and Gradle, Git, and more.
- Data Tools Platform
- Git integration for Eclipse
- Eclipse Java Development Tools
- Eclipse Java EE Developer Tools
- Maven Integration for Eclipse
- Eclipse Plug-in Development Environment
— Essential tools for developers working with C/C++ applications, including a Java IDE, tools for JavaScript, TypeScript, JavaServer Pages and Faces, Yaml, Markdown, Web Services, JPA and Data Tools, Maven and Gradle, Git, and more.
- C/C++ Development Tools
- Git integration for Eclipse
— Essential tools for developers working with PHP, including PHP language support, Git client and editors for JavaScript, TypeScript, HTML, CSS and XML.
- Git integration for Eclipse
- PHP Development Tools (PDT)
- Eclipse XML Editors and Tools
… otherwise install them:
Help > Eclipse Marketplace… > popular > Install > Agree > Trust > Reload
7. Fix Eclipse (after a bad update)
Find you Eclipse install location folder
/home/popos/.var/app/org.eclipse.Javascript/eclipse/eclipse
Remove the cache folder
rm -rf /home/popos/.var/app/org.eclipse.Javascript/eclipse/eclipse/.p2/org.eclipse.equinox.p2.repository/cache
Reboot eclipse:
cd /home/popos/.var/app/org.eclipse.Javascript/eclipse/eclipse/
./eclipse & disown
Config file:
cat /home/popos/.var/app/org.eclipse.Javascript/eclipse/eclipse/configuration/config.init
#This configuration file was written by: org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxFwConfigFileParser
#Thu Jun 06 13:52:57 UTC 2024
eclipse.application=org.eclipse.ui.ide.workbench
eclipse.buildId=4.32.0.20240606-1231
eclipse.p2.data.area=@config.dir/../p2
eclipse.p2.profile=epp.package.jee
eclipse.product=org.eclipse.epp.package.jee.product
org.eclipse.equinox.simpleconfigurator.configUrl=file\:org.eclipse.equinox.simpleconfigurator/bundles.info
osgi.bundles=reference\:file\:org.eclipse.equinox.simpleconfigurator_1.5.300.v20240424-1301.jar@1\:start
osgi.bundles.defaultStartLevel=4
osgi.framework=file\:plugins/org.eclipse.osgi_3.20.0.v20240509-1421.jar
osgi.framework.extensions=reference\:file\:org.eclipse.osgi.compatibility.state_1.2.1000.v20240213-1057.jar
osgi.instance.area.default=@user.home/workspace
osgi.splashPath=platform\:/base/plugins/org.eclipse.epp.package.common
It`s also possible to manual update Eclipse, just download and extract version to /home/popos/.var/app/org.eclipse.Javascript/eclipse/eclipse/ ad overright files.
Plugins will need to be reinstalled!
8. New Java Project
- Launch
eclipse
- Choose an workspace folder
/home/$USER/eclipse_workspace
- Create a new “Java Project”
- Choose “File” menu ⇒ “New” ⇒ “Java project” (or “File” ⇒ “New” ⇒ “Project” ⇒ “Java project”).
- “Project name”, enter “
FirstProject
". - Check “Use default location”.
- In “JRE”, check “Use an execution environment JRE” and select “JavaSE-18"
- Still in “JRE”, click in “Configure JREs” and select the compiler level to make sure the workspace compiler has the same version as the JRE select at previous step.
- In “Project Layout”, check “Use project folder as root for sources and class files”.
- In “Module”, UNCHECK “Create module-info.java” file.
- Push “Finish” button.
- IF “Create module-info.java” dialog appears, Click “Don’t Create” (This will not appear if you do step 2(e)).
9. Write a Hello-world Java Program (or “Java Class”)
- In the “Package Explorer” (left pane) ⇒ Right-click on “
FirstProject
" (or use the "File" menu) ⇒ New ⇒ Class. - The “New Java Class” dialog pops up.
- In “Source folder”, keep the “FirstProject”.
- In “Package”, leave it EMPTY. Delete the content if it is not empty.
- In “Name”, enter “
Hello
". - Check “
public static void main(String[] args)
". - Don’t change the rest.
- Push “Finish” button.
- The source file “
Hello.java
" opens on the editor pane (the center pane). Enter the following codes:
public class Hello {
public static void main(String[] args) {
System.out.println("hello, world");
}
}
10. Compile & Execute the Java Program
- There is no need to compile the Java source file in Eclipse explicitly. It is because Eclipse performs the so-called incremental compilation, i.e., the Java statement is compiled as and when it is entered.
- To run the program, right-click anywhere on the source file “
Hello.java
" (or choose "Run" menu) ⇒ Run As ⇒ Java Application. - The output “Hello, world!” appears on the Console pane (the bottom pane).
To change the JRE for any reason…
A: Configure the Build path in the “Package Explorer” (left pane) ⇒ Right-click on “JRE System Library
" ⇒ Build Path ⇒ Configure. (or “Package Explorer” (left pane) ⇒ Right-click on “FirstProject
" ⇒ Build Path ⇒ Properties ⇒ Java Build Path).
- The “Properties for FirstProject” dialog pops up.
- In “Libraries folder”, select the JRE System Library”. Select Edit…
- In “System library”, leave it EMPTY. Delete the content if it is not empty.
- In “Name”, enter “
Hello
". - Check “
public static void main(String[] args)
". - Don’t change the rest.
- Push “Finish” button, select the Execution environment: JavaSE-11 (jre)
- Push “Finish” button.
- Push “Apply and Close” button.
B: Compiler level
- Depends on your project target JVM, specify the compiler level
- Choose “Windows” menu ⇒ “Preferences” ⇒ “Java” ⇒ “Compiler”.
- And change the “Compiler compliance level”, to the specified JVM your project has as a target version. Let it unchanged for now.
IT’s my problems, maybe yours…