WSO2 Identity Server - Carbon cannot execute Java - java

I'm using Ubuntu 16.04 64-bit. I installed Oracle JDK jdk1.8.0_144 in /usr/local/java and set the symlinks as below.
$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_144/jre/bin/java" 1
$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_144/bin/javac" 1
$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_144/jre/bin/javaws" 1
$ sudo update-alternatives --set java /usr/local/java/jdk1.8.0_144/jre/bin/java
$ sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_144/bin/javac
$ sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_144/jre/bin/javaws
After that, I followed the installation guide in the WSO2 documentation and set JAVA_HOME as below.
nano /.bashrc
added the variable:
export JAVA_HOME=/usr/local/java/jdk1.8.0_144
export PATH=${JAVA_HOME}/bin:${PATH}
I close the old terminals and open a new one and run:
echo $JAVA_HOME
and I get
/usr/local/java/jdk1.8.0_144
However, when I run sh wso2server.sh I get the error:
JAVA_HOME is not defined correctly.
CARBON cannot execute java
error.

You should try to add the following into your .bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/jre/bin:$PATH
There is similar issue: Ubuntu: JAVA_HOME is not defined correctly
There are many other causes of this issue:
1) You are running the server as the super user (sudo) which is not required. However I think you dont have the JAVA_HOME set in super user environment.
2) You can try: sudo JAVA_HOME=/usr/lib/jvm/java-7-oracle ./wso2server.sh
3) You should probably be setting JAVA_HOME to /usr/lib/jvm/jdk1.7.0/jre rather than /usr/lib/jvm/jdk1.7.0.
4) Your version of Identity Server does not support java 8.

replace your java home path in wso2server.sh line no 52
#JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home

Related

update-alternatives: error: alternative /usr/lib/jvm/jdk1.8.0_312/bin/java for java not registered; not setting

I am trying to install Java Developer Kit 8 by running the following commands:
sudo apt-get update
sudo apt-get install -y openjdk-8-jdk
echo 'Updating eventually the correct version of Java...'
var=$(java -version 2>&1 | awk -F '"' 'NR==1 {print $2}') # get the actual version
sudo update-alternatives --set java /usr/lib/jvm/jdk${var}/bin/java
The problem is that I am getting the following error:
default: Updating eventually the correct version of Java...
update-alternatives: error: alternative /usr/lib/jvm/jdk1.8.0_312/bin/java for java not registered; not setting
Is there a missing step in the commands?
I'm somewhat confused. You're directly invoking the java command, which will use the java that's already redirected in in the alternatives configuration. You are literally attempting to set the default java to the java that you've just installed? If you don't change anything, then it should already be pointing to this instance of java.
Secondly, you're assuming that the path to java is the one you're specifying there. It doesn't have to be the case. When I create a minimal docker container with openjdk-8-jdk (and dpkg, so update-alternatives is available), then the path to java is:
root#c330511a7cde:/# update-alternatives --list java
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
So the path that you should have been using was this path.
Now I've manually installed a few more java versions, and because of priorities, java-17 is now the default java, so the output is a bit longer:
root#c330511a7cde:/# update-alternatives --list java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
/usr/lib/jvm/java-17-openjdk-amd64/bin/java
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
In this case, you're probably better finding the java-8 path from update-alternatives and setting it that way, so something like:
java_8_path=$(update-alternatives --list java | grep 'java-8-openjdk' | head -1)
if [ -n "$java_8_path" ]; then
sudo update-alternatives --set java "$java_8_path" || echo "darn"
else
echo "could not find java8 in alternatives list" 1>&2
fi

Error occurred during initialization of VM Server VM is only supported on ARMv7+ VFP

Attempting to make a Minecraft server with my Rasberry pi and I the error above when running the command java -version. I have reinstalled java and the same occurs. I have a raspberry pie 3 B+.
Any help would be appreciated thanks
Per the instructions posted by pi4j https://pi4j.com/documentation/java-installation/
Luckily there are different suppliers providing ready-made packages of
the JDK for multiple platforms. But only Azul seems to have one which
is a perfect fit for Raspberry Pi’s with an ARMv6
So you'd need first to check your board version:
$ cat /proc/cpuinfo
If it has ARMv6 then you need to substitute your Java
$ cd /usr/lib/jvm
$ sudo wget https://cdn.azul.com/zulu-embedded/bin/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz
$ sudo tar -xzvf zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz
$ sudo rm zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz
Now update alternatives
$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/java 1
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/javac 1
Then select the newly installed one
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac
And here you go, check your new version
$ java -version

OpenTSDB no JDK found

I'm having troubles starting OpenTSDB because no JDK is found allthough I've installed it and set JAVA_HOME. Here's what I've done:
1. Install JDK
sudo apt-get install openjdk-8-jdk
2. Set JAVA_HOME
I tried setting JAVA_HOME in 2 different ways:
Add JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64" to /etc/environment
Add export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64" to .bashrc
3. Download OpenTSDB
wget https://github.com/OpenTSDB/opentsdb/releases/download/v2.3.0/opentsdb-2.3.0_all.deb
4. Install OpenTSDB
dpkg -i opentsdb-2.3.0_all.deb
5. Start OpenTSDB
service opentsdb start
Each time I get the error "* no JDK found - please set JAVA_HOME". I've tried numerous times, what am I doing wrong?
This issue is also present in opentsdb 2.3.1. To fix this issue you should explicitly write your JAVA_HOME to the opentsdb init script (at /etc/init.d/opentsdb)
open the file /etc/init.d/opentsdb and add the path to your java installation
here is the fix:
JDK_DIRS=" Path_to_your_JDK_here \
/usr/lib/jvm/java-8-oracle /usr/lib/jvm/java-8-openjdk \
/usr/lib/jvm/java-8-openjdk-amd64/ /usr/lib/jvm/java-8-openjdk-i386/ \
\
/usr/lib/jvm/java-7-oracle /usr/lib/jvm/java-7-openjdk \
/usr/lib/jvm/java-7-openjdk-amd64/ /usr/lib/jvm/java-7-openjdk-i386/ \
\
/usr/lib/jvm/default-java"
Do you try with these command after install jdk?
update-alternatives --display java
update-alternatives --config java
with this command select default JDK for the system.
Regards!

purge doesn't uninstall java 6?

I'm using Vagrant to simulate a network for a distributed system project. I'm using this file provision.sh in order to provision each machine in the cluster:
sudo apt-get update
sudo apt-get install -y openjdk-7-jdk
sudo apt-get purge -y openjdk-6-jre
sudo apt-get purge -y openjdk-6-jre-lib
sudo apt-get install -y maven
echo "export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386" >> /home/vagrant/.profile
echo "export PATH=$JAVA_HOME/bin:$PATH" >> /home/vagrant/.profile
mvn clean -f /vagrant/RaftFS/pom.xml
mvn package -f /vagrant/RaftFS/pom.xml
sudo mv /vagrant/RaftFS/target/RaftFS-1.0-SNAPSHOT-jar-with-dependencies.jar /vagrant/
sudo cp /vagrant/RaftFS/servers.yaml /vagrant/
But when I access to the VM and I run java -version it says that the version 6 is still installed! How is that possible? As suggested by #ydaetskcoR if I execute env | grep JAVA_HOME it returns JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386 ...so I don't get why it says that the java version is 6
Just for completeness, this is the Vagrant file:
# -*- mode: ruby -*-
# # vi: set ft=ruby :
# Specify minimum Vagrant version and Vagrant API version
Vagrant.require_version ">= 1.6.0"
VAGRANTFILE_API_VERSION = "2"
# Require YAML module
require 'yaml'
# Read YAML file with box details
servers = YAML.load_file('RaftFS/servers.yaml')
# Create boxes
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Iterate through entries in YAML file
servers.each do |key,value|
config.vm.define key do |srv|
srv.vm.box = value['box']
srv.vm.network "private_network", ip: value['ip']
srv.vm.hostname=key
srv.vm.synced_folder ".", "/vagrant" , disabled:true
srv.vm.synced_folder "ServersFS/"+key+"/", "/vagrant/ServersFS" , create: true
srv.vm.synced_folder "./RaftFS", "/vagrant/RaftFS"
srv.vm.provision :shell, path: "provision.sh"
srv.vm.provider :virtualbox do |vb|
vb.name = key
vb.memory = value['ram']
end
end
end
end
and this is servers.yaml file:
hal9000:
box: hashicorp/precise32
ram: 512
ip: 172.17.8.101
ftpPort: 8080
skynet:
box: hashicorp/precise32
ram: 512
ip: 172.17.8.102
ftpPort: 8081
jarvis:
box: hashicorp/precise32
ram: 512
ip: 172.17.8.103
ftpPort: 8083
After installing new Java version, you must to inform your system where your Oracle Java JDK/JRE is located and with version must be used as default. This will tell the system that the new Oracle Java version is available for use.
For this you must use "update-alternatives", something like this:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_20/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_20/bin/javac" 1
sudo update-alternatives --set java /usr/local/java/jdk1.8.0_20/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_20/bin/javac
Change paths to your openjdk-7-jdk files
I found out by myself the answer to my problem: I had simply to update the system's alternatives with these two commands:
sudo apt-get install icedtea-7-plugin
sudo update-java-alternatives -s java-1.7.0-openjdk-i386
The first one is necessary since this error would be thrown otherwise:
update-java-alternatives: plugin alternative does not exist: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/IcedTeaPlugin.so
Now if I run java -version the correct version (7) is returned.

Error thrown in update-alternatives

I am trying to install jdk for 32-bit OS. Followed the below steps,
wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" http://download.oracle.com/otn-pub/java/jdk/6u38-b05/jdk-6u38-linux-i586.bin
chmod u+x jdk-6u34-linux-i586.bin
./jdk-6u34-linux-i586.bin
mkdir -p /usr/lib/jvm /usr/bin/java /usr/bin/javac /usr/bin/javaws
mv jdk1.6.0_3./usr/lib/jvm/`
update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_38/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_38/bin/javac" 1
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jre1.6.0_38/bin/javaws" 1
but while running cmd 6 i am getting below error. Any help would be appreciated.
update-alternatives: warning: forcing reinstallation of alternative /usr/lib/jvm/jdk1.6.0_38/bin/java because link group java is broken.
update-alternatives: warning: not replacing /usr/bin/java with a link.
update-alternatives: warning: forcing reinstallation of alternative /usr/lib/jvm/jdk1.6.0_38/bin/javac because link group javac is broken.
update-alternatives: warning: not replacing /usr/bin/javac with a link.
update-alternatives: error: alternative path /usr/lib/jvm/jre1.6.0_38/bin/javaws doesn't exist.
if you need to install java in Ubuntu, you can try using following command and you will get oracle-java-installer in your synaptic package manager, click it and install it.
sudo add-apt-repository ppa:webupd8team/java
Else try following steps
$ wget http://download.oracle.com/otn-pub/java/jdk/6u34-b04/jre-6u34-linux-i586.bin
$ chmod u+x jre-6u34-linux-i586.bin
$ ./jre-6u34-linux-i586.bin
$ sudo mkdir -p /usr/lib/jvm
$ sudo mv jre1.6.0_34 /usr/lib/jvm/
$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jre1.6.0_34/bin/java" 1
$ sudo update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/usr/lib/jvm/jre1.6.0_34/lib/i386/libnpjp2.so" 1
$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jre1.6.0_34/bin/javaws" 1
The issue is that you have created a folder named "java" in /usr/bin . Remove the folder from /usr/bin and run the command again.
Instead of Step 4 :
4. mkdir -p /usr/lib/jvm /usr/bin/java /usr/bin/javac /usr/bin/javaws
Just use
$mkdir -p /usr/lib/jvm
and make sure that you are moving the files to usr/lib/jvm , for that use
$mv -v jre1.6.0_34 /usr/lib/jvm/
so that you can see the details and after installation change the configuration of java and javaws by :
$update-alternatives --config java
select from the option
similarly ,
$update-alternatives --config javaws
this should work if you have already another java installed
Remove folder java from /usr/bin and try again

Categories

Resources