This question already has answers here:
Java command not found on Linux
(6 answers)
Closed 6 years ago.
i try to run spark application on a cluster standalone mode, when i access to some remote machines and use "java -version" command i get the information(java version ..), but on others i get an error
-bash: command not found
so i thought that maybe java is not installed on those nodes so i tried with:
sudo apt -get install openjdk-8-jdk
but i get the same error, so wanna know how can i fix this, and i have some questions:
-Is it necessary that i install java on all remote machines? or if i install it only on the master node it is enough?
-if i have to install it on each node, how can i fix the problem that i explained before? (can not use install command...)
-In my code, i used expressions that are only supported with jdk 8, but some nodes (in which i could get "java version") it is installed jdk7, so do i have to reinstall jdk8 ?
"command not found" error means that particular command you're trying to invoke is not found in neither of directories listed in $PATH system variable.
There are two ways how to fix this:
1) Specify full path when running an executable:
/opt/jdk-12345/bin/java -version
2) add the very same path to the beginning of PATH (change will be applied to current session only):
export PATH=/opt/jdk-12345/bin:$PATH
java -version
To fix this permanently, add that line (export PATH=/opt/jdk-12345/bin:$PATH) to ~/.bashrc (if BASH is default shell for that user) or to ~/.profile
Also because this is Unix Java, make sure to set up LD_LIBRARY_PATH and CLASSPATH variables if you're running some server applications. Usually this is done in application startup scripts, no need to go global.
Please verify which Server OS you're running ( uname -a or /bin/uname -a ) because different Unix systems have different package managers: apt-get is for Ubuntu/Debian, rpm for RedHat, Entropy for Sabayon/Gentoo, etc...
Related
I want to run JMeter test plans from a UNIX server where env variables for java is not set. Its a test server and I dont have access to set that. We have different JDK versions and all are sitting in directories. I need to run my JMeter TestPlans on this server. I went to JDK /bin folder and tired to execute the below command
$ {jmeter-path}/bin/jmeter -nt testplan.jmx -l testresult.jtl
but this says
./bin/java: not found
But if I do simple java -version it shows the version result.Is that something that JMeter needs specifically the java env variable set or it wont run ? I dont have permission to set and I want to run the testplan using the JDK/JRE from its directories. A help would be appreciated. Thanks in advance!
UPDATE:
I think I could work around this by editing the jmeter script file as suggested in the one of the comments. Since my requirement was running the JMeter from a specific server, I could achieve this by editing the JAVA_HOME variable value in the script.
JMeter looks for java executable in system PATH so you have 2 options:
Add bin folder of your JDK or JRE to PATH, something like:
PATH=$PATH:/location/of/your/jbk/bin && export PATH && {jmeter-path}/bin/jmeter -nt testplan.jmx -l testresult.jtl
Or if you have java in PATH just run ApacheJMeter.jar like:
java -jar {jmeter-path}/bin/ApacheJMeter.jar
You might also want to use jmeter.sh wrapper script instead of jmeter, it has some logic regarding java binary location
More information: Get Started With JMeter: Installation & Tests
The official JMeter Getting Started documentation says this:
To install a release build, simply unzip the zip/tar file into the directory where you want JMeter to be installed. Provided that you have a JRE/JDK correctly installed and the JAVA_HOME environment variable set, there is nothing more for you to do.
Based on the symptoms that you reported, I think that you have not set JAVA_HOME correctly. It should be set to an absolute path to your Java installation's top directory.
I need to uninstall Java jdk1.6.0.27 from RHEL 5.7 and then install another version jre-7u40-linux-x64.rpm.
The firs thing I did was to find out the current java version installed using the
java -version command and the output is "java version "1.6.0_27"".
After that I tried to check the previews version of java with the command:
rpm -qi jdk
The output is "package jdk is not installed"
After installing the package jre-7u40-linux-x64.rpm in the /usr/java directory there are two java packages.
The output of the ls command on /usr/java is:
default jdk1.6.0_27 jre1.7.0_40 jre-7u40-linux-x64.rpm latest.
when I run the command "alternatives --config java" the output is:
*+ 1 /usr/java/latest/bin/java
I am new to RHEL and I need some help to understand the situation.
To conclude I need some help to remove the previews jdk1.6.0.27 and to install jre1.7.0_40.
Thank you in advance for your help!
Best regards,
Claudio
First, find out your real java executable. Start with
which java
This is going to give you some response such as:
/usr/bin/java
Next, do
ls -l /usr/bin/java
(Or whatever it returned).
It will probably write something like:
/usr/bin/java -> /etc/alternatives/java
Do the same for whatever is pointed to by the arrow, until finally, when you do ls -l on it, there is no arrow.
Then, for that particular file, find out which rpm provides it by using
rpm -q -f <full path of the file you found>
It should tell you which package it belongs to, and then you can uninstall that.
However, if the rpm command returns The file ... is not owned by..., then your Java has not been installed using an rpm. It may have been installed manually by someone in the past.
This makes uninstalling it a lot more problematic.
If you haven't found your answer:
leave old java where it is, don't even bother with it
install new version with: rpm -ivh /root/jdk-7u40-linux-x64.rpm
deactivate old java
export new version
Deactivating old java (note entering hashtags before every line, manual installation required editing of profile, so edit it one more):
vi /etc/profile
#JAVA_HOME=/usr/java/jdk1.6.0_27
#export JAVA_HOME
#PATH=$JAVA_HOME/bin:$PATH
#export PATH
Exporting nev version (note adding new lines in profile followed after old entries):
export JAVA_HOME=/usr/java/latest
export JRE_HOME=$JAVA_HOME/jre
export J2RE_HOME=$JAVA_HOME/jre
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$J2RE_HOME/bin:$PATH
Check nev version with standard command for checking of installed sw.
Hope this suits your needs.
Just wondering: you're trying to prepare BFBOX for acceptance? Just courious! If you want more info please send me an email, ok?
I have installed Java 1.7.0_45 on Mac OS X 10.6.8 using Pacifist [http://www.charlessoft.com/] however I am unable to run a jar file which I have downloaded. The jar file is a threaded application.
The error message I am getting is:
java -jar context.jar
2013-10-31 14:14:41.898 java[330:a07] *** NSInvocation: warning: object 0x109356390 of class 'ThreadUtilities' does not implement methodSignatureForSelector: -- trouble ahead
2013-10-31 14:14:41.900 java[330:a07] *** NSInvocation: warning: object 0x109356390 of class 'ThreadUtilities' does not implement doesNotRecognizeSelector: -- abort
Trace/BPT trap
Is there anyway I can run the jar. I have set the JAVA_HOME path properly and java -version is showing 1.7.0_45 as the version.
The same application works properly on Windows Java 1.7.0_45 and also on Linux Java 1.7.
The web search for the solution and the given keywords return very few results and none of them have any specific solution in it. I am new to mac so I am not fully able to understand the issue.
Alternatively, is there anyway I can run Java from folder in Mac like I can do in windows and Linux by just extracting the Java contents and changing the JAVA_HOME. If that is possible then I should be able to run my JAR.
I had kind of same problem while installing an application through jar file, my Java was not detected by the jar application installer,
Over here I see that one of the method is not accessible, could be a same problem. But I am not very sure of it.
make sure you have rt.jar in your JAVA_HOME/jre/lib/ folder
In case you don't have then you are required to have it through the process of creation of symbolic link.
In the command below replace your_java_version with proper version matching your requirement.
sudo mkdir -p /System/Library/Frameworks/JavaVM.framework/Versions/<your_java_version>/Home/jre/lib
Go into the directory:
cd /System/Library/Frameworks/JavaVM.framework/Versions/<your_java_version>/Home/jre/lib/
Create symbolic link :
sudo ln -s ../../../Classes/classes.jar rt.jar
Hope this solves your problem.
I get the exact same problem with MacOS 10.6.8 and JDK 7. In order to run the jar I had to use the System JRE which is 1.6.x (In my case I wanted to install Squirrel
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -jar >squirrel-sql-3.6-MACOSX-install.jar
I did have JDK installed, and also put $JDK_HOME/bin on my PATH. However, I still have problem to install Java EE. Could you guys give me some hints? Thanks.
dav#Bruno:~$ ls
[some stuff...]
33511405_3645.jpg glassfish stuff
bea hplip-3.11.12-plugin.run temp
bin hpscan001.png Templates
C03_08.txt java_ee_sdk-6u4-jdk7-linux.sh Tomcat
c4c jdk1.7.0_10 Ubuntu One
[some stuff2...]
dav#Bruno:~$ echo $PATH
/home/dav/jdk1.7.0_10/lib:/usr/share/java:/home/dav/jdk1.7.0_10:/home/dav/jdk1.7.0_10/bin:/home/dav/Fluent.Inc/bin:/home/dav/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/dav/jdk1.7.0_10/lib:/usr/share/java
dav#Bruno:~$ sudo sh java_ee_sdk-6u4-jdk7-linux.sh
Could not locate a suitable jar utility.
Please ensure that you have Java 6 or newer installed on your system
and accessible in your PATH or by setting JAVA_HOME
dav#Bruno:~$
I think the problem you're facing is that the PATH variable you're looking at is set for the user 'dav', but because you're sudoing the sh command, the PATH changes to that of root, which probably doesn't contain the JDK.
I think you should try explicitly setting the JAVA_HOME environment variable, try running:
sudo JAVA_HOME=/home/dav/jdk1.7.0_10 sh java_ee_sdk-6u4-jdk7-linux.sh
in case someone still gets frustrated over this:
("Could not locate a suitable jar utility.
Please ensure that you have Java 7 or newer installed on your system
and accessible in your PATH or by setting JAVA_HOME")
First of all make sure you are not using "sudo" to install java ee.
when you use sudo you use a different environment (root, with not necessarily the same
environment variables). in this case (ee installation) sudo is not required.
In other (which ever) cases when root access is required make sure the required user/system variables are set on system level, not (just) on user level.
to set variables at system level instead of user level define the variables in a system level script, i.e. /etc/profile or /etc/profile.d
otherwise, if you are not using SUDO trying to install jee, and still have this "JAVA_HOME not set"-problem, try this:
the cause seems to be the JAVA_HOME variable that can not be found by the install script.
therefore adjust ~/.bashrc to define JAVA_HOME.
JAVA_HOME of course has to point to your oracle java (se/jdk) installation. If you haven't installed it, that's the first thing to do. JAVA_HOME should point at the root directory of the installation (not to the bin directory in it), i.e.:
export JAVA_HOME=/usr/local/jdk1.7.1_02.
Next change path like so:
PATH=$JAVA_HOME:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
keep the faith
don't let frustrations get the better of you (perhaps making you take it out on your colleagues or loved ones :o )
don't allow stress to build up too much. take a break in time to watch a funny video or
take a stroll to the coffee machine, or have a little chat with that cute person a couple of desks away from you.
You'll need to create an update alternative for the "jar" executable like:
sudo update-alternatives --install "/usr/bin/jar" "jar" "/usr/lib/jvm/jdk1.6.0/bin/jar" 1
Note: You may need to use appropriate path in your case.
When I run MATLAB install script in Ubuntu, I get the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class java.awt.Component
longer output is available here
I know that it's a Java problem and could potentially be fixed by changing the classpath or something like that but I don't exactly know how.
Any Ideas?
For me this error was fixed when I installed the JRE on my system:
apt-get install default-jre
on Ubuntu 12.04, instead of having MATLAB use its own.
I've been battling this problem for the whole evening as well but I stumbled onto a solution that works for me at least.
After trying to install using the silent installer I got a different error with a bit more information. It turned out that a library was missing (libXtst.so.6). I was able to install that on my Ubuntu system with:
apt-get install libxtst6
After that I tried running the GUI installer (over X forwarding) and it looks like it's going to work now.
For MATLAB R2012a Student Edition, in Ubuntu 14.04, I had to install these prerequisites first:
sudo apt-get install default-jre libxtst6:i386 libXext6:i386 libxi6:i386 libncurses5:i386 libxt6:i386 libxpm4:i386 libxmu6:i386 libxp6:i386
Next I installed/activated per MATLAB's instructions (sudo ./install). I answered "yes" when the installer asked to add a symbolic link in /usr/local/bin/
Finally, when launching MATLAB, I have to specify that it run in 32-bit mode:
matlab -glnx86
I assembled those steps from this answer: https://askubuntu.com/questions/363878/how-to-install-32-bit-matlab-in-ubuntu-64-bit
and the Ubuntu MATLAB guide:
https://help.ubuntu.com/community/MATLAB
Optional
I didn't want to type the -glnx86 option each time I launch MATLAB, so I replaced the matlab symbolic link in /usr/local/bin/ with a script that automatically specifies the -glnx86 option:
ls -l /usr/local/bin/matlab #note the destination of the symbolic link
sudo mv /usr/local/bin/matlab /usr/local/bin/matlab.bak
#ensure the first path below matches your symbolic link's destination
echo '/usr/local/MATLAB/R2012a_Student/bin/matlab -glnx86 "$#"' | sudo tee /usr/local/bin/matlab
sudo chmod +x /usr/local/bin/matlab
With that, I can type 'matlab' and it launches properly. (The "$#" in the script forwards all input arguments to matlab.) There's probably a more elegant way to accomplish this, but it worked.
I also encountered a "/lib/libc.so.6: not found" error on matlab startup, which I fixed by following this answer.
Installing gnome (sudo apt-get install gnome) fixed this problem for me. I'm sure this was total overkill, but the required libraries are now available.