I did these steps without error:
JDK path :
Downloads/jdk-6u37-linux-x64.bin
Commands in Terminal:
mkdir Programs
cd Programs
bash ../Downloads/jdk-6u37-linux-x64.bin
ln -s jdk-6u37-linux-x64 jdk
Set JAVA_HOME and Path:
I added the following lines to the end of the .bashrc file:
export JAVA_HOME=$Home/Programs/jdk
export PATH=:$JAVA_HOME/bin:$PATH
This is the result of executing the command echo $JAVA_HOME:
/Programs/jdk
This is the result of executing the command echo $PATH:
:/Programs/jdk/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games1
And the problem is:
This is the result of executing the command
$ java -version
The program 'java' can be found in the following packages:
* default-jre
* gcj-4.6-jre-headless
* gcj-4.7-jre-headless
* openjdk-7-jre-headless
* openjdk-6-jre-headless
Try: sudo apt-get install
I think the problem is that environment variables are case sensitive in linux, so your
export JAVA_HOME=$Home/Programs/jdk
Should be
export JAVA_HOME=$HOME/Programs/jdk
In your echo $JAVA_HOME output you can see that you don't get your /home/yourname prepended...
Hope that helps.
Cheers,
The scripts located here will help you install sun's jdk on Ubuntu. Really useful stuff.
try this command
sudo update-alternatives --config java
This will list all the Java versions installed and configured.
If you see one or more installs, it will give you a list each element starting with a number. Just choose the number that corresponds to the version you want to use by default.
Related
I'm on windows 10 and running the bash shell (ubuntu), by turning the Windows Subsystem for linux on. Anyways, I'm trying to run some Java programs through the command prompt. I have already set the PATH variables and I can successfully run the java and javac commands in the windows command prompt. However, when I run the javac or java command using Ubuntu shell it says those commands are not found? So it lists some options that I can enter and one of those is
sudo apt install openjdk-8-jdk-headless
But when I run this command it says:
E: Unable to locate package openjdk-8-jdk-headless
I don't get it. I already have Java-8 installed and the PATH variables set, it works fine for the windows command prompt but fails to work with ubuntu. What am I doing wrong?
Thanks.
Do you have to use the OpenJDK version? Try this
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
See this link and this issue
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!
I am using the machine image available here to host an RStudio server off of EC2 on which I will want to run analysis, in part using xlsx and rvest, both of which require Java and R to cooperate which they do not out of the box. I searched for a few solutions and tried to implement them, but got pretty much nowhere.
I SSH'd into the machine, and entered java -version and got this:
The program 'java' can be found in the following packages:
* default-jre
* gcj-5-jre-headless
* openjdk-8-jre-headless
* gcj-4.8-jre-headless
* gcj-4.9-jre-headless
* openjdk-9-jre-headless
Try: sudo apt install <selected package>
so I'm not sure what to do with that. I tried running sudo apt-get install r-cran-rjava which was also recommend on StackOverflow, and got this error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package r-cran-rjava
and likewise when I try to run sudo R CMD javareconf this is what I get:
*** JAVA_HOME is not a valid path, ignoring
*** Cannot find any Java interpreter
*** Please make sure 'java' is on your PATH or set JAVA_HOME correspondingly
I searched for Java it's stored here: java: /usr/share/java and I'm not sure how to set JAVA_HOME correctly, or how to set Java correctly.
What should I do?
Installing RJava (Ubuntu)
First, we need Java itself, check if it's installed
Write in Terminal: java -version
but you already checked it, so you need to install it.
If it returns The program java can be found in the following packages, then Java hasn't been installed yet, so execute the following command: sudo apt-get install default-jre. This will install the Java Runtime Environment (JRE).
Then Install JDK
Write in Terminal: sudo apt-get install default-jdk
Then assotiate the JDK installed with R
Run in Terminal: sudo R CMD javareconf
Install RJava and Rgdal
Execute: sudo apt-get install r-cran-rjava
Then: sudo apt-get install libgdal1-dev libproj-dev
Install package in RStudio
Run in RStudio: install.packages("rJava")
Done!
In Oracle Enterprise Linux when I type java I am getting
bash: java: command not found
I have installed Java 1.6 and I have the following
sudo update-alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
* 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
+ 2 /usr/java/jre1.6.0_24/bin/java
How can I resolve this issue?
Thanks
You can add one of the Java path to PATH variable using the following command.
export PATH=$PATH:/usr/java/jre1.6.0_24/bin/
You can add this line to .bashrc file in your home directory. Adding this to .bashrc will ensure everytime you open bash it will be PATH variable is updated.
I had these choices:
-----------------------------------------------
* 1 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
+ 2 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
3 /home/ec2-user/local/java/jre1.7.0_25/bin/java
When I chose 3, it didn't work. When I chose 2, it did work.
I found the best way for me was to download unzip then symlink your new usr/java/jre-version/bin/java to your main bin as java.
I use the following script to update the default alternative after install jdk.
#!/bin/bash
export JAVA_BIN_DIR=/usr/java/default/bin # replace with your installed directory
cd ${JAVA_BIN_DIR}
a=(java javac javadoc javah javap javaws)
for exe in ${a[#]}; do
sudo update-alternatives --install "/usr/bin/${exe}" "${exe}" "${JAVA_BIN_DIR}/${exe}" 1
sudo update-alternatives --set ${exe} ${JAVA_BIN_DIR}/${exe}
done
Execute: vi ~/.bashrc OR vi ~/.bash_profile
(if above command will not allow to update the .bashrc file then you can open this file in notepad by writing command at terminal i.e. "leafpad ~/.bashrc")
add line : export JAVA_HOME=/usr/java/jre1.6.0_24
save the file (by using shift + Z + Z)
source ~/.bashrc OR source ~/.bash_profile
Execute : echo $JAVA_HOME
(Output should print the path)
I was having the same problem on my ec2 machine. Below these 2 commands helped me to fix the issue.
sudo yum update
sudo yum install java-11-amazon-corretto
I tried to mvn install and got this message:
Compilation failure
Unable to locate the Javac Compiler in:
/usr/lib/jvm/java-7-openjdk-amd64/jre/../lib/tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
Well, there is an open jdk, I also downloaded another one. I tried to point JAVA_HOME to both, now it is set:
JAVA_HOME=/usr/lib/jvm/jdk1.7.0_03
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
I also tried to choose one of those open with sudo update-alternatives --config java but got the same error with different jdk versions in it.
How can I fix that? Thanks in advance.
it seems like your PATH is not picked up correctly... does the output of "echo $PATH" contain the directory where javac resides?
I would suggest following:
open terminal and do an:
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_03
export PATH=$PATH:$JAVA_HOME/bin
javac -version
which javac
if javac -version still does not work create a symlink in /usr/local/bin pointing to your javac binary:
cd /usr/local/bin
ln -s /usr/lib/jvm/jdk1.7.0_03/bin/javac javac
this should get you up an running...
an alternative is to try setting up java via your package management system (e.g. "apt-get install java" or sth. similar)
I faced similar error on an ubuntu machine while running a maven build from Jenkins. If output of 'javac -version' prompts below messages:
"The program 'javac' can be found in the following packages:
default-jdk
ecj
gcj-5-jdk
openjdk-8-jdk-headless
gcj-4.8-jdk
gcj-4.9-jdk
openjdk-9-jdk-headless
Try: apt install "
Then you can install "openjdk-8-jdk-headless" using:
apt install openjdk-8-jdk-headless
This solved my problem and the maven build went through ok.