Difference between revisions of "OpenJDK as Java Platform"

From Gcube Wiki
Jump to: navigation, search
(Eclipse)
(Eclipse)
Line 106: Line 106:
 
[[File:EclipseOpenJDK2.png|200px]]
 
[[File:EclipseOpenJDK2.png|200px]]
  
4) Open all the projects to migrate to OpenJDK
 
  
5) Open the menu menu ''Windows -> Preferences''. In the dialog that opens, select ''Java > Compiler''  
+
4) Open the menu menu ''Windows -> Preferences''. In the dialog that opens, select ''Java > Compiler''  
  
 
[[File:EclipseOpenJDK4.png|200px]]
 
[[File:EclipseOpenJDK4.png|200px]]
  
6) Click on "Configure Project Specific Settings..." (top, right), you should see an empty list.
+
5) Click on "Configure Project Specific Settings..." (top, right), you should see an empty list.
  
7) Then, for each project, follow these steps:
+
6) Then, for each project, follow these steps:
  
* Right click the project and select "properties"
+
6.1) Open the project
* Select “Java Build Path” on left, then “JRE System Library”, click Edit…
+
6.2)  Right click the project and select "properties"
 +
6.3)  Select “Java Build Path” on left, then “JRE System Library”, click Edit…
 
[[File:OpenJDK8.png|200px]]
 
[[File:OpenJDK8.png|200px]]
* Select "Workspace Default JRE"
+
6.4)  Select "Workspace Default JRE"
 
[[File:OpenJDK7.png|200px]]
 
[[File:OpenJDK7.png|200px]]
* Confirm everything
+
6.5) Confirm everything
  
 
== IntelliJ IDEA ==
 
== IntelliJ IDEA ==

Revision as of 04:30, 3 May 2019

Java Platform

As of May 2019, OpenJDK 8 is the official Java platform supported by gCube. Legacy components work on JDK from Oracle and are still maintained, but active development is not done under this platform.

About OpenJDK

OpenJDK (Open Java Development Kit) is a free and open-source implementation of the Java Platform, Standard Edition (Java SE). It is the result of an effort Sun Microsystems began in 2006. The implementation is licensed under the GNU General Public License (GNU GPL) version 2 with a linking exception. Were it not for the GPL linking exception, components that linked to the Java class library would be subject to the terms of the GPL license. OpenJDK is the official reference implementation of Java SE since version 7.

OpenJDK Installation

Installation on Mac OS X

Software requirements:

Installation steps:

1) Add the distribution repository:

 
>$ brew tap AdoptOpenJDK/OpenJDK
 
==> Tapping adoptopenjdk/OpenJDK
Cloning into '/usr/local/Homebrew/Library/Taps/ adoptopenjdk/homebrew-OpenJDK'...
remote: Enumerating objects: 24, done.
remote: Counting objects: 100% (24/24), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 24 (delta 12), reused 12 (delta 5), pack-reused 0
Unpacking objects: 100% (24/24), done.
Tapped 14 casks (66 files, 81.8KB).

2) Look for available releases:

>$ brew search /adoptopenjdk/
 
==> Casks
adoptopenjdk               adoptopenjdk11-jre         adoptopenjdk12             adoptopenjdk12-openj9-jre  adoptopenjdk8-openj9
adoptopenjdk10             adoptopenjdk11-openj9      adoptopenjdk12-jre         adoptopenjdk8              adoptopenjdk8-openj9-jre
adoptopenjdk11             adoptopenjdk11-openj9-jre  adoptopenjdk12-openj9      adoptopenjdk8-jre          adoptopenjdk9

3) Install version 8:

>$ brew cask install adoptopenjdk8
 
==> Satisfying dependencies
==> Downloading ....
==> Verifying SHA-256 checksum for Cask 'adoptopenjdk8'.
==> Installing Cask adoptopenjdk8
==> Running installer for adoptopenjdk8; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
Password:
installer: Package name is AdoptOpenJDK
installer: Installing at base path /
installer: The install was successful.
 
adoptopenjdk8 was successfully installed!

4) Verify that OpenJDK 8 is the default Java platform now:

>$ java -version
OpenJDK version "1.8.0_212"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_212-b03)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.212-b03, mixed mode)

Installation on Ubuntu

Software requirements:

Installation steps: 1) Install the package:

$ sudo apt install openjdk-8-jdk

2) Set OpenJDK as default java platform:

$ sudo update-java-alternatives -s java-1.8.0-openjdk-amd64

3) Verify that OpenJDK 8 is the default Java platform now:

$ sudo update-alternatives --get-selections
idlj                           manual   /usr/lib/jvm/java-8-openjdk-amd64/bin/idlj
jar                            manual   /usr/lib/jvm/java-8-openjdk-amd64/bin/jar
jarsigner                      manual   /usr/lib/jvm/java-8-openjdk-amd64/bin/jarsigner
java                           manual   /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
java2groovy                    auto     /usr/share/groovy/bin/java2groovy
javac                          manual   /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
...

Configuration for the IDE

Eclipse

The following steps explain how to install OpenJDK as default Java Platform in Eclipse and how to configure each project to use it.

1) Open the menu Windows > Preferences. In the dialog that opens, select Java > Installed JRE

EclipseOpenJDK1.png

2) Click on "Add Standard VM"

EclipseOpenJDK3.png

3) Browse to the OpenJDK installation folder and adjust the settings:

EclipseOpenJDK2.png


4) Open the menu menu Windows -> Preferences. In the dialog that opens, select Java > Compiler

EclipseOpenJDK4.png

5) Click on "Configure Project Specific Settings..." (top, right), you should see an empty list.

6) Then, for each project, follow these steps:

6.1) Open the project 6.2) Right click the project and select "properties" 6.3) Select “Java Build Path” on left, then “JRE System Library”, click Edit… OpenJDK8.png 6.4) Select "Workspace Default JRE" OpenJDK7.png 6.5) Confirm everything

IntelliJ IDEA