Guide to running NEM on OpenJDK 8


#1

[center]Guide to Installing and Using OpenJDK 8 With NEM

Introduction: Why OpenJDK?[/center]
We live in an era where mass data collection and violations of privacy on the part of both governments and companies runs rampant. Governments want to know who is doing what and companies want to know who is using their product how; both groups are all to often willing to violate people's privacy to get this data. Many people perceive government data collection as the biggest threat because it is done is secret but this is not always true because more often than not, a government agency has to hide what they are doing because they are afraid of their citizens overthrowing them whereas companies can legally collect data in the open because nobody reads the 1 billion page long "Terms and Conditions" of using their software (believe me, they are long just for that purpose). Further, sometimes companies will share the data they collect with governments in secret because they are forced to.

In fact, these violations of privacy are so rampant that most people just accept it because they feel they have no power to avoid it. This may even be a true sentiment to some extent. That being said, it is possible to fight against it. Most opensource software has no data collection back doors because anyone can review the code and make modified versions of it. If one developer introduces a back door, another will make a version of the software without one. Even opensource software that has a foundation backing it that does participate in data collection cannot do so in secret because anyone can look at the code and call them out on it and modify their software to get rid of it. Sadly, some opensource software does openly participate in data collection by default but most have an option to disable it and you can bet that when you disable it that it is really disabled because if the option didn't work in the source code, someone would know.

Most people don't know this: the "official" version of Java (the one that comes from Oracle), is not opensource! It is based on opensource software but has some modifications to it. The opensource software it is based off of is OpenJDK, one of the biggest opensource projects on the net (and the bigger a project is, the more eyes are watching it for back doors)! This tutorial will guide you through, step by step, installing OpenJDK 8 and using it with NEM.

The version of OpenJDK we will be using is called Zulu. It is completely opensource but is different from the main OpenJDK fork. The main reason Zulu is used is because it is easier to install, but another good reason is that it receives bug fixes much more often.

Let's get started! Just find the header for your operating system and follow the instructions below!

[center]Linux[/center]

Ubuntu, Debian, and Debian Squeeze
Open the terminal.

Import the Azul public key using the following terminal command:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0x219BD9C9

If needed, type in your password and press ENTER.

The next step is to add the APT repository. This step is different depending on your Linux distro! Use the terminal command below your distro's header to add the repository:

Ubuntu:
sudo apt-add-repository 'deb http://repos.azulsystems.com/ubuntu stable main'

Debian:
sudo apt-add-repository 'deb http://repos.azulsystems.com/debian stable main'

Debian Squeeze:
sudo echo 'deb http://repos.azulsystems.com/debian stable main' > /etc/apt/sources.list.d/zulu.list

After using one of the commands above,  you need to update the information about available packages with the following command:
sudo apt-get update

Now you are ready to install. To do this, enter the following terminal command:
sudo apt-get install zulu-8

After installing, there is still some configuring to do. To start a new document in gedit to be run at startup, use the following command:
sudo gedit /etc/profile.d/java.sh

This step is different depending on if you are running a 32-bit or 64-bit operating system! Copy the text under the proper header and paste it into the "java.sh" file you just made:

32-bit:
export JAVA_HOME=/usr/lib/jvm/zulu-8/<br />export PATH=/$JAVA_HOME/bin:$PATH

64-bit:
export JAVA_HOME=/usr/lib/jvm/zulu-8-amd64/<br />export PATH=/$JAVA_HOME/bin:$PATH

After you have pasted the proper text above, save the file and close gedit.

Reboot your machine.

Now we have to switch java versions manually. This step is different depending on if you are running a 32-bit or 64-bit operating system! Enter the command under the proper header into your terminal:

32-bit:
sudo update-alternatives --set java /usr/lib/jvm/zulu-8/bin/java

64-bit:
sudo update-alternatives --set java /usr/lib/jvm/zulu-8-amd64/bin/java

After using one of the commands above, open the terminal and enter the following command to verify your installation:
java -version

Congratulations! Next time you start NEM, you should be running on Zulu OpenJDK!


#2

That's awesome!!


#3

[center]Guide to Installing and Using OpenJDK 8 With NEM

Introduction: Why OpenJDK?[/center]
We live in an era where mass data collection and violations of privacy on the part of both governments and companies runs rampant. Governments want to know who is doing what and companies want to know who is using their product how; both groups are all to often willing to violate people's privacy to get this data. Many people perceive government data collection as the biggest threat because it is done is secret but this is not always true because more often than not, a government agency has to hide what they are doing because they are afraid of their citizens overthrowing them whereas companies can legally collect data in the open because nobody reads the 1 billion page long "Terms and Conditions" of using their software (believe me, they are long just for that purpose). Further, sometimes companies will share the data they collect with governments in secret because they are forced to.

In fact, these violations of privacy are so rampant that most people just accept it because they feel they have no power to avoid it. This may even be a true sentiment to some extent. That being said, it is possible to fight against it. Most opensource software has no data collection back doors because anyone can review the code and make modified versions of it. If one developer introduces a back door, another will make a version of the software without one. Even opensource software that has a foundation backing it that does participate in data collection cannot do so in secret because anyone can look at the code and call them out on it and modify their software to get rid of it. Sadly, some opensource software does openly participate in data collection by default but most have an option to disable it and you can bet that when you disable it that it is really disabled because if the option didn't work in the source code, someone would know.

Most people don't know this: the "official" version of Java (the one that comes from Oracle), is not opensource! It is based on opensource software but has some modifications to it. The opensource software it is based off of is OpenJDK, one of the biggest opensource projects on the net (and the bigger a project is, the more eyes are watching it for back doors)! This tutorial will guide you through, step by step, installing OpenJDK 8 and using it with NEM.

The version of OpenJDK we will be using is called Zulu. It is completely opensource but is different from the main OpenJDK fork. The main reason Zulu is used is because it is easier to install, but another good reason is that it receives bug fixes much more often.

Let's get started! Just find the header for your operating system and follow the instructions below!

[center]Linux[/center]

Ubuntu, Debian, and Debian Squeeze
Open the terminal.

Import the Azul public key using the following terminal command:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0x219BD9C9

If needed, type in your password and press ENTER.

The next step is to add the APT repository. This step is different depending on your Linux distro! Use the terminal command below your distro's header to add the repository:

Ubuntu:
sudo apt-add-repository &#039;deb http://repos.azulsystems.com/ubuntu stable main&#039;

Debian:
sudo apt-add-repository &#039;deb http://repos.azulsystems.com/debian stable main&#039;

Debian Squeeze:
sudo echo &#039;deb http://repos.azulsystems.com/debian stable main&#039; &gt; /etc/apt/sources.list.d/zulu.list

After using one of the commands above,  you need to update the information about available packages with the following command:
sudo apt-get update

Now you are ready to install. To do this, enter the following terminal command:
sudo apt-get install zulu-8

After installing, there is still some configuring to do. To start a new document in gedit to be run at startup, use the following command:
sudo gedit /etc/profile.d/java.sh

This step is different depending on if you are running a 32-bit or 64-bit operating system! Copy the text under the proper header and paste it into the "java.sh" file you just made:

32-bit:
export JAVA_HOME=/usr/lib/jvm/zulu-8/<br />export PATH=/$JAVA_HOME/bin:$PATH

64-bit:
export JAVA_HOME=/usr/lib/jvm/zulu-8-amd64/<br />export PATH=/$JAVA_HOME/bin:$PATH

After you have pasted the proper text above, save the file and close gedit.

Reboot your machine.

Now we have to switch java versions manually. This step is different depending on if you are running a 32-bit or 64-bit operating system! Enter the command under the proper header into your terminal:

32-bit:
sudo update-alternatives --set java /usr/lib/jvm/zulu-8/bin/java

64-bit:
sudo update-alternatives --set java /usr/lib/jvm/zulu-8-amd64/bin/java

After using one of the commands above, open the terminal and enter the following command to verify your installation:
java -version

Congratulations! Next time you start NEM, you should be running on Zulu OpenJDK!


#4

Hi, colin012.

Thanks for post this article.

I’m very new in Nem. I wish to deploy it using Debian (Jessie) and an open sourced java. I’m installed openjdk-jre (version 8) package from jessie backports, but when I run nix.runNis.sh script, I get this error:

Exception in thread “main” java.lang.UnsupportedClassVersionError: org/nem/deploy/CommonStarter : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
/home/joaquinm/Proyectos/nem/package

Everything points at incompatibility between Nem and openjdk-jre.

I’ll test your proposal to evaluate another way to do this.

Can you figure out what’s going wrong at my scenario?

Regards.

-Joaquin


#5

I think colin012 is referring to fork of OpenJDK that is being maintained/developed by Azul Systems.

I couldn’t get openjdk-8 installed on fresh Debian Jessie (8.1), somehow backports have messed dependencies. But Azul Systems Zulu-8 installed without a hitch (https://cdn.azul.com/zulu/bin/zulu8.28.0.1-jdk8.0.163-linux_amd64.deb). Also NEM Nis started without a hitch.

I hope this helps you forward. Why are you using old Debian distribution?


#6

Hi, SirNembalot.

Youŕe right: I need JDK instead of JRE. I realized this when I faced Nem deploy directly from the sources.

I’ve been learning some details about Nem platform. I’ve left the (wrong) idea of strong dependencies between Oracle’s Java and Nem. Now, I have another problems related to building process. My goal is to make available Nem core platform in Debian distributions to development purposes.

I’m still using old Debian due to a strange reason :slight_smile: I wouldn’t. In fact, the advances I have had occurred when I started to use Stretch jails.

Your response has helped me. Thanks.

-Joaquin


#7

Nice to hear that I could help :slight_smile:

Out of curiosity: what kind of availability are you talking about? Having NEM Nis as debian package?

@rb2 has made docker installer and also debian package (though it is outdated currently)


I made installer for Nis that contains also systemd script for start/stop, it also makes other things so that NEM Nis would be more of a service, rather than program to be run as some user.
https://github.com/whatilike/NemToolsLinux

Maybe above things will help you what ever you are doing :slight_smile: Don’t hesitate to ask more.


#8

Hi,

Yes. I wish to distribute main components of the Nem infrastructure via debian packages.

I had seen @rb2’s docker project, but not his APT repository :hushed: I’m downloading it right now to test it.

Anyway, I had planned to take some interesting ideas and scripts from @rb2’s docker solution when I reached this project first time. I thought it was an excellent work.

In my country we begin to talk about blockchain and we are involved in development projects that follow this line.

Doubly grateful, man.


#9

Our company used the services [SPAM LINK] . We needed internal telecommunications. It’s interesting whether the data they listen to will not use against us in the future? in the contract there was nothing like this.

admin edit: removed spam link