I had successfully installed java on my linux system. When I ran a hello world test sample from desktop it ran successfully, but then after few days when I again tried to run it from terminal using javac command it gave me following response:
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: sudo apt install <selected package>
When I test my JAVA_HOME env. variable using echo $JAVA_HOME its showing:
/usr/lib/jvm/java-8-openjdk-amd64
its also there with PATH variable.
When I ran a which java command its showing:
/usr/lib/jvm/java-8-openjdk-amd64/bin/java
and with command whereis java its showing:
java: /usr/lib/jvm/java-8-openjdk-amd64/bin/java /usr/share/man/man1/java.1.gz
So, I don't understand the problem, as I, myself applied the env. variables, and its showing everything perfect, then why is not javac command running? can any one look into this problem.
The core problem is that you do not have the Java Develoment Toolkit (which is different than the Java runtime) installed on your system. This means that utilities used to create Java programs (such as javac, jar, etc) are not on your system.
Thorbjørn Ravn Andersen gave the answer for Debian-family Linux systems, here's the answer for RedHat-family systems
yum install java-devel
or if you are on the latest Fedora
dnf install java-devel
Undo your environment settings and run sudo apt install openjdk-8-jdk. javac should now be in your path.
Just my 5 cents.
On CentOS 7 (assuming you want LTS Java 11):
sudo yum install java-11-openjdk-devel
/usr/lib/jvm/java-8-openjdk-amd64/bin/java
is not an dir, its an excecuteable.
try excecute the following to use javac:
/usr/lib/jvm/java-8-openjdk-amd64/bin/javac
or
/usr/lib/jvm/java-8-openjdk-amd64/bin/jstack
Related
I was following an online tutorial on how to delete JVM 6 and install JVM 7 to be able to run eclipse on my Mac running OS X 10.9.2. First I installed the latest JDK.
I was instructed to type the following commands to delete JVM 6.
sudo rm -rf /System/Library/Java/JavaVirtualMachines/
sudo rm /private/var/db/receipts/com.apple.pkg.JavaForMacOSX*
sudo emacs /Library/Receipts/InstallHistory.plist
Then, I set the symlinks for java 7, with these commands.
sudo rm /usr/bin/java
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin/java /usr/bin/java
This should be it. Now my computer does not have any version of Java on it:
the command "java -version" responds with "java: command not found"
I also cannot direct to the folder with cd Library/Java responding with "Folder does not exist", however I can browse to that folder manually.
Can someone please assist me in getting Java 7 running on my computer so I can use eclipse.
Any help much appreciated and keep in mind I'm a Mac newb.
this is the tutorial i followed:
http://www.cc.gatech.edu/~simpkins/teaching/gatech/cs2340/guides/java7-macosx.html
Did you change the PATH variable to point to the newer version?
/usr/libexec/java_home is the starting point for switching java versions on the command line. Check out this post to understand how to handle different java versions on the Mac.
I think that the folder still exists but executables didn't existe because anh version of Java is installed.
Normally you have just to download the jdk or jre on oracle web site and run the package downloaded
I tried to install netbeans 'netbeans-7.2.1-ml-linux.sh' on my ubuntu12.04
But when i am executing this .sh file i am gettig the exception given below.
Configuring the installer...
Searching for JVM on the system...
Extracting installation data...
Running the installer wizard...
Can`t initialize UI
Running in headless mode
Exception: java.awt.HeadlessException thrown from the UncaughtExceptionHandler in thread "main"
You need to install Java Runtime Environment
sudo aptitude install default-jre
Refer to this answer:
netbeans installation error: can't initialize ui running in headless mode
Worked for me. For some reason, with OpenJDK the installer was unable to open a GUI.
The Problem is the support of openJDK for the UI.
The solution is installing Oracle JDK, open your terminal and write the following commands:
sudo apt-get remove openjdk*
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
sudo apt-get install oracle-java7-set-default
after that reinstall netbeans.
You're missing a X-Server for installation (java.awt.HeadlessException). The installation script needs a UI.
For some reason the sh installer does not work with the openJDK 7.
Quick fix to install is to change back to JDK 6.
run:
sudo update-alternatives --config java
(select java 6)
sh netbeans-7.2.1-ml-linux.sh
the installer should run and then just switch back to the java 7 JDK with update-alternatives.
In my case, I had openjdk installed, where /usr/bin/java was point to the installed openjdk.
I solved it by installing the Oracle JDK 7, from a tar.gz file. Extract the tar ball to a location say your $HOME directory.
After that
I modified the .bashrc file and modified the PATH variable to
PATH=$HOME/jdk1.7/bin/:$PATH export PATH
Remember the path to your jdk/bin should be appended to PATH, as as result the system will find the java executable in your path rather than picking the installed openjdk.
Note: I chose not to uninstall installed openjdk, as most of my Libreoffice and other installed applications were depending on it.
First you have to update
sudo apt-get update
Then default java
sudo apt-get install -f default-jre
sudo apt-get install -f default-jdk
And should be done.
This is what fixed it for me:
I installed the Java JDK. In this case:
sudo aptitude install openjdk-8-jdk
Here's the kicker: I made sure that my Home and Path variables were set properly. Again, in my case:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk
export PATH=$PATH:/usr/lib/jvm/java-8-openjdk/bin
My initial issue was not having the JDK installed. It was then not having the environment variables properly set. If they aren't properly set, the installer won't launch. Simple as that.
my configurations are
hduser#worker1:/usr/local/hadoop/conf$ jps
The program 'jps' can be found in the following packages:
* openjdk-6-jdk
* openjdk-7-jdk
Ask your administrator to install one of them
I have java installed though
hduser#worker1:/usr/local/hadoop/conf$ java -version
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre10-0ubuntu5)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
hduser#worker1:/usr/local/hadoop/conf$ echo $JAVA_HOME
/usr/lib/jvm/java-1.6.0-openjdk
and also set up in conf/hadoop-env.sh
hduser#worker1:/usr/local/hadoop/conf$ cat hadoop-env.sh | grep JAVA_HOME
# The only required environment variable is JAVA_HOME. All others are
# set JAVA_HOME in this file, so that it is correctly defined on
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk
How can I make JPS work?
Saurabh Saxena's answer above is no longer correct.
To get jps, you want to also install the development tools java-1.6.0-openjdk-devel.
On CentOS 6 the file is:
java-1.6.0-openjdk-devel.x86_64
So:
yum install java-1.6.0-openjdk*
will do the trick (also picks up demo and javadocs besides the jdk and dev tools, but you will get the full complement of command line tools).
For Ubuntu:
apt-get install java-1.6.0-openjdk-devel
For all these examples, you can try JDK7 (just substitute 1.7), and as of December 2012, Hadoop is pretty stable without the Oracle libraries. See: http://openjdk.java.net/install/
This might also be a reason. Its simple: See if $javac works. Note: $java might work, check javac. If $javac is not working then $jps will not work either.
So you might want to do something like
export PATH=$PATH:$JAVA_HOME/bin
and try again. both javac and jps.
good luck.
I have found the solution for the missing JPS command. I was installing Hadoop 1.x on ubuntu machine in a pseudo distributed mode. I used Java-7-openJDK to provide for the Java commands and tools. For some reason there was a java-1.6.0-openjdk-devel for version 6 but none for version 7 specifically debian and ubuntu distributions. I am not sure if the same is true for Fedora and Redhat. So the best answer as that time was using the linux command
ps -aux | grep java
I hated doing that because Hadoop daemons start with so many options that each result fills up more than a screen. Apart from seeing that java is running it is impossible to see what hadoop daemons are running. Hence i came up with a short soultion in the form of one line shell script
This is my JPS scirpt for open JDK
!#/bin/bash
ps -aux | grep java | awk '{print $12}'
END
I saved these two lines in a file named jps and stored it in the hadoop/bin directory with execute permissions
**Here is the result of the script
hduser#localhsot# ./jps
-Dproc-namenode
-Dproc-datanode
-Dproc-JobTracker
-Dproc-TaskTracker**
It seems like open-jdk does not have jps in it.
For hadoop, installing sun-jvm would be a better choice.
try this....
sudo apt-get install openjdk-7-jdk
I would like to update topic for those who would face the same problem.
JDK8 also does not have the "jps" command but JDK7 does have it.
root#tahirpc:/home/tahir# java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.3) (**7u71-2.5.3-0ubuntu0.14.04.1**)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
root#tahirpc:~# jps
5036 NodeManager
4368 NameNode
4912 ResourceManager
5315 Jps
4773 SecondaryNameNode
4487 DataNode
Use sudo apt-get install openjdk-7-jdk and not openjdk-7-jre. .
For java 8 in ubuntu use the following command.
sudo apt install openjdk-8-jdk-headless
For Hadoop, Oracle JDK 6 preferred, I am not sure if someone has used OpenJDK with Hadoop successfully without any patches. FYI, there had been some talks about support for JDK 7 also. For now, there is too much dependency on Oracle JDK. Hope the dependency goes away soon.
I found it
rpm -qlp java-1.6.0-openjdk-devel-1.6.0.0-1.39.1.9.7.el6.x86_64.rpm | grep jps
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/bin/jps
then
rpm -i java-1.6.0-openjdk-devel-1.6.0.0-1.39.1.9.7.el6.x86_64.rpm
Open syneptics package manager and install openjdk-7-jdk and openjdk-6-jdk package. AFter that jps will work
I have been following this tutorial, and at step 5, I am getting the following output from GCC:
HelloWorld.c:1:17: error: jni.h: No such file or directory
In file included from HelloWorld.c:3:
HelloWorld.h:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
HelloWorld.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
I know that he include directories vary from system to system, so I tried to adapt the command accordingly, but I cannot seem to find the correct directory on my system. I am using Ubuntu 10.04LTS.
Open up a terminal and type:
locate jni.h
That should tell you where every file called jni.h is on your system. I am on ubuntu 11.04, and it's located at:
/usr/lib/jvm/java-6-openjdk/include/jni.h
/usr/lib/jvm/java-6-sun-1.6.0.26/include/jni.h
You may also need to get it from the repos:
sudo apt-get install openjdk-6-jdk
should do the trick if you don't have it installed.
jni.h lives with JDK. For me it is: jdk1.6.0_25/include/.
And by default, I don't think Ubuntu would have JDK with development libraries, so download latest JDK version from Oracle and install it somewhere.
Or you can install openjdk as #Leif suggested if it works on 10.04 LTS. Although, I personally, prefer the one from Sun/Oracle.
In Ubuntu 14.04 run:
sudo apt-get install openjdk-7-jdk openjdk-7-jre-lib
Now, you have a headers into /usr/lib/jvm/java-7-openjdk-amd64/include
For OpenJDK 6:
sudo apt-get install openjdk-6-jdk openjdk-6-jre-lib
I am putting together a dev environment for a Java program and after the first try of my Ant build scripts I got this error:
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar
While the path to the jdk is correct, the tools.jar really wasn't there. Is it actually supposed to be there or did I get some config/installation thing wrong?
It seems like you can have Java installed in /usr/lib/jvm/java-6-openjdk but only have the JRE, not the JDK. This fixed it for me:
sudo apt-get install openjdk-6-jdk
Note: On CentOS / RHEL installing java-1.x.0-openjdk will not be enough. Also install java-1.x.0-openjdk-devel.
It's there on my machine. I'm running Sun JDK 1.6.0_21 on Windows XP SP3.
Are you sure you have the JDK? Is it possible that you only have the JRE?
On Debian, after installing Ant with apt-get install ant, I've encountered the same error when running it:
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk-amd64/lib/tools.jar
Indeed, there's no mention of any tools.jar anywhere in /usr/lib, although /usr/lib/jvm/java-6-openjdk-amd64 itself does exist.
https://packages.debian.org/search?searchon=contents&keywords=java-6-openjdk-amd64%2Flib%2Ftools.jar
As per the search above, java-6-openjdk-amd64/lib/tools.jar appears to be part of openjdk-6-jdk, which indeed didn't get installed with ant (since it's only marked as suggested (https://packages.debian.org/wheezy/ant)).
apt-get install openjdk-6-jdk
apt install defalut-jdk # this doesn't contain some file, like tools.jar...
apt install openjdk-8-jdk # this contains all files.
On Ubuntu I've just need to install JDK
sudo apt-get install openjdk-7-jdk
..and you can always search for all available versions with
$ sudo apt-cache search openjdk | grep ^openjdk
From the website https://openjdk.java.net/install/ we can read
The openjdk-7-jre package contains just the Java Runtime Environment. If you want to develop Java programs then install the openjdk-7-jdk package.
Try the following:
% sudo apt-get install sun-java6-jdk
% sudo update-alternatives --config java
select the option that has the path
/usr/lib/jvm/java-6-sun/jre/bin/java
Worked for me on an ubuntu 10.4
u can try to put your JAVA_HOME also, as follows:
% sudo export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")
Installing the jdk-6u45-linux-x64.bin (from the oracle.com site) via unzip does not result in a tools.jar. I guess that file is created by the "make-jpkg" script. Once I did that, and installed the resulting .deb file, everything was fine.
I really hate oracle's lawyers.
Even if you have jdk installed, you'll need to redirect JAVA_HOME to point to it.
Here's one weird trick you can put into your .profile to set JAVA HOME properly, no matter which java you have:
export JAVA_HOME=$(dirname $(dirname $(readlink -e /usr/bin/java)))
# Test for jdk installed above jre
if [ -x $JAVA_HOME/../bin/java ]; then export JAVA_HOME=$(dirname $JAVA_HOME); fi
On Ubuntu I've fixed this problem by installing package
openjdk-7-jre-lib
tools.jar appeared after that.
(I know this is an old post, but comment in hope that it will be helpful for somebody lurking for answer like I was today.)