Unix Java Issue - java

Ok, I'm trying to install Websphere (from IBM) on my Ubuntu 12.04 LTS Server.
But when it cames to install the .bin, it says no Java VM can be found on the server, but when I get the Java version it's fine.
Here's the response I get when I run this commands:
$ sudo path/*.bin
Preparing to install ...
Extracting the installation resources from the installer archive..
Configuring the installer for this system's environment...
no Java virtual machine could be found from your PATH environment variable. You must install a VM prior to running this program.
$ java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build pxi3260sr12-20121025_01(SR12))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 Linux x86-32 jvmxi3260sr12-20121024_126067 (JIT enabled, AOT enabled)
J9VM - 20121024_126067
JIT - r9 20120914_26057
GC - 20120925_AA)
JCL - 20121014_01
$ cat /etc/environment
JAVA_HOME="/opt/ibm/java-i386-60"
JRE="$JAVA_HOME/jre"
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/imb/java-i386-60/bin:/opt/ibm/java-i386-60/jre/bin"

When you use sudo, the command is run as root and not as the current user. You need to configure root's $PATH to include Java.
Try sudo java -version to see if Java is property configured for root (it sounds like it isn't).

Related

Not able to start sqldeveloper without sudo in Ubuntu

I installed Oracle SQL Developer following an article online in my Virtual Box Ubuntu.
My Ubuntu has IBM ACE 11 Developer Edition installed. So when I type java -version at terminal (user), I got this:
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 8.0.6.20 - pxa6480sr6fp20ifix-20210224_01(SR6 FP20+IJ30974))
IBM J9 VM (build 2.9, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20210223_466229 (JIT enabled, AOT enabled)
OpenJ9 - 5b31a42
OMR - 4eb8f5f
IBM - b7e48f4)
JCL - 20201119_01 based on Oracle jdk8u271-b0
But in my root terminal , my java -version is
java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)
JAVA_HOME in both .bashrc and /etc/profile are set to usr/lib/jvm/jdk1.8.0_291 (newly downloaded JDK as per the article)
First question is why I have set those JAVA_HOME path to the same one, but java -version in user account is not the JDK that I installed newly.
# update-alternatives --list java
/opt/IBM/ace-11.0.0.12/common/jdk/jre/bin/java
/usr/lib/jvm/jdk1.8.0_291/bin/java
I have set to use the newly installed java (/usr/lib/jvm/jdk1.8.0_291/bin/java) using the sudo command update-alternatives --set java ....
I am able to start sqldeveloper using root. But not able to start sqldeveloper using user account where I have set the SetJavaHome to newly installed Java path.
I tried this https://askubuntu.com/questions/566721/sql-developer-runs-in-terminal-with-sudo-sqldeveloper-but-not-without-sudo where it asked to change the file ownership. But still it doesn't work
I got error when trying to start sqldeveloper
Oracle SQL Developer
Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
/usr/lib/jvm/jdk1.8.0_291/bin/java: relocation error: /usr/lib /jvm/jdk1.8.0_291/jre/lib/amd64/libnio.so:
symbol initInetAddressIDs version SUNWprivate_1.1 not defined in file libnet.so with link time reference
Second question is how can I approach to solve the error when starting sqldeveloper without using root?
The bashrc and other profile based scripts like bash_profile etc., that are executed on login are different for different users. Maybe the root users bashrc does not have this JAVA_HOME or might have a different version altogether. So make sure the files in the home directory of both these users are have the same version. For more information you can check What's the difference between .bashrc, .bash_profile, and .environment?
The error states that symbol initInetAddressIDs version SUNWprivate_1.1 not defined in file libnet.so. This might be an issue of java setup. The .so libraries being fetched might be mixed up. It might work once you fix up 1st issue.

Cordova picking up wrong version of java

I am trying to run
cordova build android
It gives the following error
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=/home/bappaditya/Softwares/android-studio (recommended setting)
ANDROID_HOME=/home/bappaditya/Softwares/android-studio (DEPRECATED)
Requirements check failed for JDK 8 ('1.8.*')! Detected version: 12.0.2
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.
I can see that it has picked up ANDROID_HOME and ANDROID_SDK_ROOT but not the correct version of java
My current environment
>java -version
openjdk version "1.8.0_275"
OpenJDK Runtime Environment (build 1.8.0_275-8u275-b01-0ubuntu1~20.04-b01)
OpenJDK 64-Bit Server VM (build 25.275-b01, mixed mode)
>echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64
>echo $PATH
/home/bappaditya/.cargo/bin:/opt/gradle/gradle-5.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/bappaditya/bin:/usr/lib/jvm/java-8-openjdk-amd64/bin
As you can see the JAVA 8 is installed and set as default. Why cordova complaining about java version?
It seems cordova uses javac to identify the version and not java.
So the command that really shows the version cordova gets when looking for Java is:
javac -version
In my case, even though I had identical versions to what you have in your environment, it turned out my javac was pointing to a newly updated Java (from Ubuntu updates)
To fix it, I used the update-alternatives command and set javac back to my 1.8.0 version as follow:
sudo update-alternatives --config javac

JDK 14.0.1 installed and "No Java runtime present, requesting install"

I found similar issues but none addressing the issue recently.
In a fresh installed Java, for the record:
java -version
openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.1+7)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.20.0, JRE 14 Mac OS X amd64-64-Bit Compressed References 20200416_40 (JIT enabled, AOT enabled)
OpenJ9 - 05fa2d361
OMR - d4365f371
JCL - 5757187cae based on jdk-14.0.1+7)
I'm trying to execute a simple:
javaws
And getting a
No Java runtime present, requesting install.
Unable to locate a Java Runtime to invoke.
In the aforementioned similar problems, the people correlated this to the lack of JAVA_HOME, which is not the case here:
echo $JAVA_HOME
/Users/fbarbeiro/.sdkman/candidates/java/current/bin/java
I'm using a MacOS High Sierra version 10.13.3which I cannot update due to external dependencies.
Any clue in what could have been causing the No Java runtime present, requesting install. Unable to locate a Java Runtime to invoke.?
Thanks
javaws is the command to start the Java Web Start launcher.
Java Web Start was deprecated in Java 9 and removed in Java 11. You can downgrade from 14 to 10, or look for alternatives. I found this with an Internet search: https://openwebstart.com/

How PyCharm runs without JRE although it is made using Swing?

Is PyCharm made using Java-Swing?
If it is, then how does it runs on a PC where JDK or JRE hasn't been set up yet?
When I look at my own PyCharm installation directory structure, I see a jre64 directory, which contains a Java installation.
And that seems to be a normal JRE:
$ ./pycharm-community-2018.2.4/jre64/bin/java -version
openjdk version "1.8.0_152-release"
OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b8)
OpenJDK 64-Bit Server VM (build 25.152-b8, mixed mode)
So PyCharm comes with a Java distribution which it uses (even instead of an already available Java installation). Instead of my pre-installed and configured java 1.8.0_191, it uses the version it comes bundled with:

Failed to install jdk 1.7 on mac

I'm trying to install JDK 1.7 update 21 on Mac OSX 10.7 .
I downloaded the installer from oracle site (as dmg file). ran the installer which completed successfully.
Now I can't find the java SDK anywhere on the file system.
The output of /usr/libexec/java_home -V is :
***/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home***
which is the previous version installed.
also running java -version executes the same old version.
***Java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)***
In the java control panel I do see that the JRE has updated to Java 1.7 for the browser but there aren't any details regarding the JDK there.
Where can I find the new JDK on the file system and how do I set it as default ?
Is there any log file for the installation that I can use to debug ?
Try adding this to your shell startup script (.bash_profile off of ~ if you are using bash):
export JAVA_HOME=`/usr/libexec/java_home -v '1.7*'`
The changeover from Apple providing the JDK to Oracle has been a complete disaster.

Categories