Difference between revisions of "OpenJDK as Java Platform"

From Gcube Wiki
Jump to: navigation, search
 
(20 intermediate revisions by the same user not shown)
Line 8: Line 8:
 
= OpenJDK Installation =
 
= OpenJDK Installation =
  
== Installation on Mac OS X ==
+
== On Mac OS X ==
 
'''Software requirements:'''  
 
'''Software requirements:'''  
 
* [https://brew.sh/ Homebrew]  
 
* [https://brew.sh/ Homebrew]  
Line 53: Line 53:
 
adoptopenjdk8 was successfully installed!
 
adoptopenjdk8 was successfully installed!
 
</source>
 
</source>
4) Verify that OpenJDK 8 is the default Java platform now:  
+
4) Verify that OpenJDK 8 is the default Java platform:  
 
<source lang="bash">
 
<source lang="bash">
 
>$ java -version
 
>$ java -version
Line 61: Line 61:
 
</source>
 
</source>
  
== Installation on Ubuntu ==
+
== On Linux Ubuntu ==
 
'''Software requirements:'''  
 
'''Software requirements:'''  
 
* [https://help.ubuntu.com/lts/serverguide/apt.html.en Advanced Package Tool, or APT]  
 
* [https://help.ubuntu.com/lts/serverguide/apt.html.en Advanced Package Tool, or APT]  
Line 67: Line 67:
  
 
'''Installation steps:'''
 
'''Installation steps:'''
 +
 
1) Install the package:
 
1) Install the package:
 
<source lang="bash">
 
<source lang="bash">
Line 77: Line 78:
 
</source>
 
</source>
  
3) Verify that OpenJDK 8 is the default Java platform now:  
+
3) Verify that OpenJDK 8 is the default Java platform:  
 
<source lang="bash">
 
<source lang="bash">
 
$ sudo update-alternatives --get-selections
 
$ sudo update-alternatives --get-selections
Line 89: Line 90:
 
</source>
 
</source>
  
= Configuration for the IDE =
+
= IDE Configuration =
  
 
== Eclipse ==
 
== Eclipse ==
1) Add OpenJDK as JDK:
+
The following steps explain how to configure OpenJDK as default Java Platform in Eclipse and how to set each project to use it.
  
Select the menu ''Windows > Preferences''. In the new windows, select ''Java -> Installed JRE'' .
+
=== Default Compiler ===
 +
1) Open the menu ''Windows > Preferences''. In the dialog that opens, select ''Java > Installed JRE''
  
 +
[[File:EclipseOpenJDK1.png|350px]]
 +
 +
2) Click on "Add Standard VM"
 +
 +
[[File:EclipseOpenJDK3.png|200px]]
 +
 +
3) Browse to the OpenJDK installation folder and adjust the settings:
 +
 +
[[File:EclipseOpenJDK2.png|200px]]
 +
 +
4) Open the menu menu ''Windows -> Preferences''. In the dialog that opens, select ''Java > Compiler''
 +
 +
[[File:EclipseOpenJDK4.png|400px]]
 +
 +
5) Click on "Configure Project Specific Settings..." (to the top-right), you should see an empty list.
 +
 +
=== Project configuration ===
 +
 +
6) 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…
 +
 +
[[File:OpenJDK8.png|400px]]
 +
 +
6.4)  Select "Workspace Default JRE"
 +
 +
[[File:OpenJDK7.png|300px]]
 +
 +
6.5) Confirm everything
  
 
== IntelliJ IDEA ==
 
== IntelliJ IDEA ==
 +
 +
The following steps explain how to configure OpenJDK as default Java Platform in IntelliJ IDEA and how to set each project to use it.
 +
 +
1) Open the project to migrate.
 +
 +
2) Open the Project Structure dialog (menu ''File > Project Structure'').
 +
 +
3) In the leftmost panel, under Platform Settings, click SDKs.
 +
 +
4) Above the panel to the right, click + and select JDK.
 +
 +
[[File:IntelliJOpenJDK1.png|200px]]
 +
 +
5) In the dialog that opens, select the installation directory of OpenJDK to be used and click OK.
 +
 +
[[File:IntelliJOpenJDK2.png|200px]]
 +
 +
6) If necessary, configure your custom profile and specify the preverify options on the SDK page (in the right-hand part of the dialog).
 +
 +
[[File:IntelliJOpenJDK3.png|300px]]
 +
 +
7) Click OK in the Project Structure dialog.
 +
 +
[[Category:Continuous_Integration]]

Latest revision as of 04:10, 8 July 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

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:

>$ 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)

On Linux 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:

$ 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
...

IDE Configuration

Eclipse

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

Default Compiler

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..." (to the top-right), you should see an empty list.

Project configuration

6) 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

The following steps explain how to configure OpenJDK as default Java Platform in IntelliJ IDEA and how to set each project to use it.

1) Open the project to migrate.

2) Open the Project Structure dialog (menu File > Project Structure).

3) In the leftmost panel, under Platform Settings, click SDKs.

4) Above the panel to the right, click + and select JDK.

IntelliJOpenJDK1.png

5) In the dialog that opens, select the installation directory of OpenJDK to be used and click OK.

IntelliJOpenJDK2.png

6) If necessary, configure your custom profile and specify the preverify options on the SDK page (in the right-hand part of the dialog).

IntelliJOpenJDK3.png

7) Click OK in the Project Structure dialog.