java/javac -version command reponse with nothing - java

First, I'm using CentOS v6.1
I installed openjdk 8 and extracted it.
I set $JAVA_HOME, $JRE_HOME $PATH in ~/.bash_profile like below.
export PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME=/home/software/jdk8u222-b10
export JRE_HOME=/home/software/jdk8u222-b10/jre
I've also used source ~/.bash_profile in command line.
But when I type $ /home/software/jdk8u222-b10/bin/java -version or java -version,
it shows nothing to me even 'not found' errors. => image
How can I solve this problem?
I think it is not an environment path problem
When I directly execute jdk/bin/java file, it shows nothing to me.

It was server-side problem.
Old version of glibc and java was conflicted.
After upgrade glibc, the conflict did not occurred.

Related

Unable to get PATH to be set for all users

Trying to get OpenJDK 17 installed for Pufferpanel. User pi can do java -version fine however Pufferpanel gets bash: java: command not found
My /etc/profile and /etc/profile.d/java.sh have these lines:
#JAVA
export JAVA_HOME="/usr/lib/jvm/jdk-17.0.1+12"
export PATH=$JAVA_HOME/bin:$PATH
In addition JAVA_HOME="/usr/lib/jvm/jdk-17.0.1+12" is set in /etc/environment
Full permissions have been given for java.sh and the JAVA_HOME folder with chmod 777. The user pufferpanel now can run the script however the error stays the same: bash: java: command not found.
Trying some things out and found this:
pufferpanel#raspberrypi:/home/pi$ whereis java
java: /usr/share/java
Meanwhile pi gives this output:
pi#raspberrypi:~ $ whereis java
java: /usr/share/java /usr/lib/jvm/jdk-17.0.1+12/bin/java
Good news is that Java does run as the user pufferpanel:
pufferpanel#raspberrypi:/usr/lib/jvm/jdk-17.0.1+12/bin$ ./java -version
openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment Temurin-17.0.1+12 (build 17.0.1+12)
OpenJDK Server VM Temurin-17.0.1+12 (build 17.0.1+12, mixed mode, sharing)
My guess is that PATH is getting overwritten somewhere, just don't know where.
If there are easier ways to install Java that is higher than version 16 just to get Minecraft to work, please tell me!
What you are doing is fine, but you should probably create a custom.sh shell script in /etc/profile.d/
As for environment variables, like JAVA_HOME, they should go in /etc/environment
Setting the PATH in ~/.bashrc worked out, copied java.sh and pasted it in. Couldn't find ~/.bashrc at first, but this helped to figure that out.
As Pufferpanel is a different matter, I'm marking this the answer to my question which was getting Java to work as an user.

installed java 7 but terminal responds with version 6

So I installed Java 7 and verified that it was installed Java now shows up under System preferences. However when I run java -version it still returns
java version "1.6.0_65
How do i fix this so that my computer points to the correct version? Also, is this a problem in the future if i choose to not fix this?
Thanks
You need to set your java 7 directory bin path to system PATH variable. As you are using Mac OS, use this article to set path correctly:
JAVA HOME in Mac OS
Use the following command to list the installed versions of Java:
/usr/libexec/java_home -V
From the output of the above command, copy the path for the version of Java you want to use.
Open up your ~/.bash_profile or ~/.bashrc file and add/edit the line:
export JAVA_HOME=/Path/copied/from/step/2
In your terminal, reload the the file you edited in the previous step using the corresponding command below:
source ~/.bash_profile
source ~/.bashrc
Now, you should see the the correct version of Java on the command line:
java -version

Explicitly need to reload the system wide PATH . /etc/profile everytime for JAVAC to work in Ubuntu12.04

I have installed JAVA 1.8.0_05 using the following tutorial;
http://www.wikihow.com/Install-Oracle-Java-on-Ubuntu-Linux
After configuring my path in . /etc/profile as shown below I rebooted my Ubuntu
JAVA_HOME=/usr/local/java/jdk1.8.0_05
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/local/java/jdk1.8.0_05/jre
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Everything works fine up to the point where I give java -version but JAVAC -VERSION is not recognized. Now when I reload the system PATH using . /etc/profile, it works ( I mean JAVAC -version works).
Can you please help me and fix this problem permanently? So that I don't have to reload the system path again and again..
(Note: Without loading the system path every time, my JAVA -version works fine)
From document https://help.ubuntu.com/community/Java
Run this command from terminal
sudo update-alternatives --config javac

export JAVA_HOME not working

The version of Java I have installed on my machine is:
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.11.90) (amazon-62.1.11.11.90.55.amzn1-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
To set the path of JAVA_HOME, I wrote the following command in the ~/.bashrc file:
export JAVA_HOME=/usr/lib/jvm/default-java/
The command echo $JAVA_HOME gives the output /usr/lib/jvm/jre. I am assuming this is the wrong path, or am I wrong ?
And these are the files I have in the directory /usr/lib/jvm
java-1.6.0-openjdk-1.6.0.0.x86_64
jre
jre-1.6.0
jre-1.6.0-openjdk.x86_64
jre-openjdk
You should try doing the same using ~/.bash_profile , and ~/.profile as well... Then logoff and login, and see if it works using java --version
If files don't exist, then create them, add the export, and give them execution permissions using chmod +x .profile .bash_profile
It seems that maybe default-java is a symbolic link to all versions of java installed on your machine. Have you tried setting it to a specific java jdk bin?
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/
Check your javac program path using:
whereis javac
In debian based distributions use
sudo update-alternatives --display javac
To find out where your javac program resides, also (if you have several jdk's installed) update-alternatives lets you change the default javac
Update your JAVA_HOME in your ~/.bashrc and then type: source ~/.bashrc, then print again echo $JAVA_HOME, the change should apply immediately

unable to run sqldeveloper on debian

I have installed jdk1.6.0_21 and sqldeveloper(using alien) on debian(lenny). Now when I run sqldeveloper it asks for J2SE installation path, after I type the jdk path it exits with the below error message.
Oracle SQL Developer
Copyright (c) 2008, Oracle. All rights reserved.
Type the full pathname of a J2SE installation (or Ctrl-C to quit), the path will be stored in ~/.sqldeveloper/jdk
/usr/java/jdk1.6.0_21
/opt/sqldeveloper/sqldeveloper/bin/../../ide/bin/launcher.sh: line 430: /root/.sqldeveloper/jdk: No such file or directory
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
Error: SQL Developer can't recognize the JDK version
You might want to issue the following command:
echo '/usr/lib/jvm/java-6-sun' > ~/.sqldeveloper/jdk
also it can be
/usr/lib/jvm/java-6-openjdk
on the sqldeveloper home there is a file named sqldeveloper.sh (or datamodeler.sh) add the folowin line:
unset GNOME_DESKTOP_SESSION_ID
should be look like this:
#!/bin/bash
unset GNOME_DESKTOP_SESSION_ID
cd "`dirname $0`"/sqldeveloper/bin && bash sqldeveloper $*
That's all.
Adios
There are several possible causes for this error message:
The VM can't find the rt.jar file
The VM and the rt.jar file don't match (e.g. VM is version 1.6.x, rt.jar is version 1.4)
The JDK wasn't installed properly
What's the output of the following commands?
which java
java -version
/usr/java/jdk1.6.0_21/bin/java -version
Finally I found the problem, JDK was not installed properly. I installed a fresh copy of OpenJDK after that it is working fine.
I've got the same when i will install my SQL Developer as root, but use it as other user.. In my case looks like the Sql developer was makes file ~/.sqldeveloper/.... as root:root privilegies, but in home dir with sudo user.. It's strange but easy to fix as
chown youruser:yourgroup -R ~/.sqldeveloper
When you get several error messages that don't seem to make any sense, start by looking at the first error. In this case, that would be:
/root/.sqldeveloper/jdk: No such file or directory
It looks like sqldeveloper is trying to write the file, and failing. Are you running this as root? If not, can you think of any reason why sqldeveloper would think that your home directory is /root/?
It looks as if the two java versions (OpenJDK accessible via /usr/bin/java and JDK 1.6.0_21 get mixed up). I can only guess how it can be solved:
run update-alternatives --set java /usr/java/jdk1.6.0_21/bin/java
try to uninstall OpenJDK
possibly, you need to do both
Only replace in /opt/sqldeveloper/sqldeveloper/bin/sqldeveloper.conf
from:
SetJavaHome ../../jdk
to:
SetJavaHome /usr/lib/jvm/java-7-openjdk-amd64

Categories