Use different Java versions on single Ubuntu 18.04.4 LTS server - java

I have Jenkins server which works on Java 8 but, he should make mvn install before deployment. But compiled applications use Java 14.
After Java 14 was installed, Jenkins starting crash with
$ sudo service jenkins start Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
With Java 14
$ java -version
java version "14.0.1" 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
Jenkins not work.
How I can be sure what Jenkins runs with the 8th version but my app compiling with the 14th version without Docker?
Perhaps I can use JRE from 8th and Compiler from 14th somehow? Or use 8th as active and 14th only for compile but how?
Java:
$ update-java-alternatives --list
java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64
java-14-oracle 1091 /usr/lib/jvm/java-14-oracle
Ubuntu: Ubuntu 18.04.4 LTS

I am not a Java/Jenkins developer.
Generally, in these cases where multiple program versions are involved, setting the application configuration to use a specific Java version works best, if the application supports that kind of configuration of course. You should check whether you can specify either of Jenkins or the compiler to use certain Java environment.
If that is not possible, then give it a try using environment variables. First, set Java 14 as the default so the compiler gets the latest version. Second, just before starting the Jenkins server, change Java environment temporarily, so that Jenkins sees Java 8 while running,
$ export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-amd64" \
&& export PATH=$JAVA_HOME/bin:$PATH \
&& java -jar jenkins.war --httpPort=8080
On another note, using Docker in these scenarios is really a good idea. You should consider that.
I hope this helps.

Related

Minecraft Client environment not running through vscode on MAC

For some reason this issue is to do with with gradle and yarn, no matter what I do to try and get the 'fabric-loom' plugin working, nothing works. It says i am using an outdated version of Java, that i'm on Java 11 (I'm not, I did 'java -version' in the bash terminal), I'm on Mac btw, and it said I'm on Java 16.0.2, which is the version it tells me to be on, I'll attach logs and some code I wrote. If someone could help me, that would be great, thanks in advance :)
Crash Log:
Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.2-bin.zip'. Build file '/Users/joeplemople/Desktop/joes blocks/build.gradle' line: 2 An exception occurred applying plugin request [id: 'fabric-loom', version: '0.9-SNAPSHOT'] Failed to apply plugin 'fabric-loom'. You are using an outdated version of Java (11). Java 16 or higher is required.
(This was outputted twice for some reason, idk why)
Terminal Code (Bash):
Displaying what versions of java I have installed JoepleMoples-MacBook-Pro:
joes blocks joeplemople$ /usr/libexec/java_home -V Matching Java Virtual Machines (2): 16.0.2, x86_64: "Java SE 16.0.2" /Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home 11.0.12, x86_64: "Java SE 11.0.12" /Library/Java/JavaVirtualMachines/jdk-11.0.12.jdk/Contents/Home
Me setting the default version of Java to Java (JDK) 16:
/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home JoepleMoples-MacBook-Pro:joes blocks joeplemople$ export JAVA_HOME=$(/usr/libexec/java_home -v 16.0.2) JoepleMoples-MacBook-Pro:joes blocks joeplemople$ java -version java version "16.0.2" 2021-07-20 Java(TM) SE Runtime Environment (build 16.0.2+7-67) Java HotSpot(TM) 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing)
Thanks in advance
:)
Open Command Palette and choose Java: Configure Java Runtime, select jdk16 for both Project JDKs and Java Tooling Runtime.
Then reload window to make change effective and see if the error goes away.

"Unrecognized option: --add-opens" Hyperledger Besu

I want to get started with Hyperledger Besu, after following the steps of the official documentation here and running the following command:
bin\besu --help
I get the following error:
C:\Users\user\Desktop\besu-1.3.9>bin\besu --help
Unrecognized option: --add-opens
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I get the same thing when running bin\besu or bin\besu -help.
I don't know if the problem is with java's installation or with hyperledger besu trying to run unvalid/unrecognised option bin\besu --add-opens. I tried uninstalling then reinstalling java but this did not solve the issue, here is java's version:
C:\Users\user>java -version
Picked up _JAVA_OPTIONS: -Xmx512m
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) Client VM (build 25.241-b07, mixed mode)
Any help would be appreciated!
I have no prior experience with the library which is in discussion, but I have just had a look at the official docs of the library which you are trying to use, and the installation instructions state that you require Java 11+ to complie
Hyperledger Besu requires:
MacOS High Sierra 10.13 or later versions
Java 11+ to compile; earlier versions are not supported.
From your question, it looks like your system is running Java8. Trying bumping it up to java 11 and try starting the binary again.
The script you're running adds --add-opens java.base/sun.security.provider=ALL-UNNAMED to the java command line that starts Besu. As others have noted, the --add-opens parameter was made available in Java 9; all it does is prevent a warning from being issued when any class uses reflection to access an internal JDK class (in this case, the Sun security package). I've been starting Besu without this parameter for weeks with no problems, so you could have simply removed the parameter from the Besu start script or -- better -- upgraded to at least the Java 11 or higher version that Besu expects. According to Oracle, this command line parameter will be removed eventually, but that's a problem for the Besu maintainers, not you.
change the java home version path from jdk8 path to jdk11 in environment variable
as
JAVA_HOME : {jdk11 directory path}

way to find all application using a particular java version in Windows server

We have got two java versions on our server Java 1.6 and Java 1.7. Is there a way to find out what are the applications that are running on the machine that calls the version. Our requirement is to uninstall Java 1.6 but our concern is that it should not affect other application that uses the version so trying to find all the application that uses it.
You can try
ps aux | grep 'java'
if you're on Linux.
(UPDATE: OP subsequently clarified that we're on Windows here.)
That will show you which Java runtimes are running which apps. In the event that you can't tell (for example, the java in the ps output may be a symlink), just invoke that directly:
$ ps aux | grep 'java'
wwheeler 52434 0.0 0.7 8279924 112772 s000 S+ 4:53PM 0:04.12 /usr/bin/java -Dorg.gradle.daemon=true -Xdock:name=Gradle -Xdock:icon=/usr/local/Cellar/gradle/2.12/libexec/media/gradle.icns -Dorg.gradle.appname=gradle -classpath /usr/local/Cellar/gradle/2.12/libexec/lib/gradle-launcher-2.12.jar org.gradle.launcher.GradleMain bootRun
wwheeler 9158 0.0 0.0 2434840 776 s002 S+ 6:07PM 0:00.00 grep java
$ /usr/bin/java -version
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)
No way to collect information about what application(s) use specific JRE instance. You must do it manually, because these information exist inside your application's configuration.
Supplement information, For finding JRE is running, Open your Task manager:
Open tab Details, find java process
Right click, then choose Properties from context menu:
You will see specific Java JRE is running.
Try this, when most of app’s, software, browsers, etc. are open/running,
Start --> System Information --> Software Environment --> Loaded Modules --> (Filter on Manufacturer and see Name, Version column
The above is for Laptop, same will hold good for server.

jmxtrans - Cannot execute

I am trying to get jmxtrans to work yet I get the below on ubuntu 12.04 and using openjdk 7.
/usr/share/jmxtrans# java -version
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
/usr/share/jmxtrans# ./jmxtrans.sh start /var/lib/jmxtrans/kafka.json
Cannot execute /usr/lib/jvm/default-java/bin/jps -l!
What does the above mean?
It seems that the jps file can't be found in the /usr/lib/jvm/default-java/bin directory. It is available in the '-devel' packages if you want to install those (yum install java-1.7.0-openjdk-devel, apt-get install openjdk-7-jre-devel). It could also be that your JAVA_HOME is not pointing to the correct place if you have multiple java versions installed.
You should not need it however, regular ps works fine. You can add a variable to your configuration that says export USE_JPS=false. The configuration can be found in /etc/default/jmxtrans.
Check out these issues for more information:
https://github.com/jmxtrans/jmxtrans/issues/89
https://github.com/jmxtrans/jmxtrans/pull/109

Running Hadoop Pi Example

I need some help running Hadoop Pi example in Windows. I have sucecssfully setup Hadoop on Windows and can see all NameNode, SecondaryNameNode, JobTracker and TaskTracker running. I can also hit urls:
http://localhost:50070/, http://localhost:50030 and http://localhost:50090/.
However when I am trying to run the in-built Pi example I am getting following exception.
$ hadoop jar hadoop/hadoop-examples-1.2.1.jar pi 4 100
Not a valid JAR: C:\cygwin\home\chandeln\hadoop\hadoop-examples-1.2.1.jar
I have also set both hadoop and java in my path.
$ java -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)
$ hadoop version
Hadoop 1.2.1
Subversion https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.2 -r 1503152
Compiled by mattf on Mon Jul 22 15:23:09 PDT 2013
From source with checksum 6923c86528809c4e7e6f493b6b413a9a
This command was run using /C:/cygwin/usr/local/hadoop/hadoop-core-1.2.1.jar
My .bashrc looks like this:
export JAVA_HOME=/cygdrive/c/Java/jdk1.7.0_40
export HADOOP_PREFIX=/cygdrive/c/usr/local/hadoop
export PATH=$PATH:$HADOOP_PREFIX/bin
Can anybody shed some light on this ?
Even though Hadoop is written in Java, it does not play well on Windows. If you really want to get up and running with Hadoop in the shortest possible time, I would recommend using Linux. You can download the free VMWare Player application, and install it on Windows. Then, download the latest version on Ubuntu, and install it as a virtual machine using VMWare Player. Then you can use your Ubuntu virtual machine to install a single node cluster of Hadoop.
If this seems like too much work, open an Amazon AWS account, and find pre-configured Hadoop machines to work with.
That is most likely due to your Java version not matching with the Jar. Try with jdk1.6.
(Looks like you are playing with YDN Hadoop?)
try
$yarn jar hadoop/hadoop-examples-1.2.1.jar pi 4 100

Categories

Resources