Error thrown in update-alternatives - java

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

Related

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

ubuntu java environment path, bash: /etc/environment: permission denied?

Using UBUNTU, I installed java 8 with the following command
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
$ sudo apt-get install oracle-java8-set-default
and I'm trying to set the java environment path as follow
$ cat >> /etc/environment <<EOL
JAVA_HOME=/usr/lib/jvm/java-8-oracle
JRE_HOME=/usr/lib/jvm/java-8-oracle/jre
EOL
but I get this error message:
bash: /etc/environment: permission denied
Assuming that you have already the following:
$sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
$ sudo apt-get install oracle-java8-set-default*
Open /etc/environment file with the following command.
sudo nano /etc/environment
N/B: You can replace nano with any other editor you like e.g atom
At the end of file, add
JAVA_HOME="/usr/lib/jvm/java-8-oracle"
The command above alone worked for me but you can also add the command below if you want.
JRE_HOME="/usr/lib/jvm/java-8-oracle/jre"
Remember the path used here was my java installation directory, if yours is the same then you don't need to change anything, otherwise use your path.
Check whether your changes persisted
$ source /etc/environment
$ echo $JAVA_HOME
https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04
Try this script, save it in a file.sh
#!/bin/bash
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install openjdk-8-jre -y
sudo cat >> /etc/environment <<EOL
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
EOL
Try with sudo
$ sudo cat >> /etc/environment <<EOL
JAVA_HOME=/usr/lib/jvm/java-8-oracle
JRE_HOME=/usr/lib/jvm/java-8-oracle/jre
EOL
Use the following lines to set the path variables in the /etc/environment
echo export JAVA_HOME=/path/to/java | sudo tee -a /etc/environment
echo export JRE_HOME=/path/to/jre | sudo tee -a /etc/environment
It should work.
Note:
You should reboot the system for changes to take effect.
And don't forget to come here after reboot and vote +1 :)-|-<
Following is the method that worked for me -
Use bashrc to create environment variable :
JAVA_HOME=/path/to/java
JRE_HOME=/path/to/jre
sudo vim ~/.bashrc
Enter Password
Press I(Key) to go in the insert mode
Write export JAVA_HOME='/path/to/java' at the end of file
Write export JRE_HOME='/path/to/jre' at the end of file
Save and Exit (:wq)

WSO2 Identity Server - Carbon cannot execute 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

JavaFX Raspberry Pi UI not showing

When trying to run a JavaFX app from Raspberry Pi B+ device running Raspbian the UI does not show up unlike when running from a PC.
The command invoked was:
java -jar app.jar
What could be the problem that the UI does not show up?
The solution is to run with this command:
sudo java -Djavafx.platform=eglfb -cp /opt/jdk1.8.0_111/jre/lib/jfxswt.jar:app.jar com.app.MainApp
After doing something similar to this:
Download
http://download.oracle.com/otn-pub/java/jdk/8u73-b02/jdk-8u73-linux-arm32-vfp-hflt.gz
sudo tar zxvf jdk-8u73-linux-arm32-vfp-hflt.gz -C /opt ->installs in
/opt
sudo update-alternatives --install /usr/bin/javac javac
/opt/jdk1.8.0_73/bin/javac 1
sudo update-alternatives --install /usr/bin/java java
/opt/jdk1.8.0_73/bin/java 1
sudo update-alternatives --config javac
sudo update-alternatives --config java
download
http://108.61.191.178/downloads/openjfx-8u40-sdk-overlay-linux-armv6hf.zip
sudo unzip openjfx-8u40-sdk-overlay-linux-armv6hf.zip -d
/opt/jdk1.8.0_73
I guess the user, who is executing the program, has no reading access on the css files. According to that the GUI can't be loaded.

Error while loading shared libraries during Java 1.6 Configuration in ubuntu

I installed Java and when I executed jps
its throwing
jps: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
The Commands I executed to configure is
sudo mkdir -p /usr/lib/jvm
sudo cp -R jdk1.6.0_45 /usr/lib/jvm/
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_45/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_45/bin/java 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_45/bin/javaws 1
sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config javaws
The above issue is due to missing command
sudo ./jdk-6u45-linux-x64.bin
Then copy command should be there.

Categories

Resources