I am working on Amazon ec2 for the first time and verified java version by using the command java -version and got the below results:
openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)
And also run the command javac -version, but no results. From this, I have understood the javac is not set and none of the java related applications are running. Can anyone please tell me how to resolve this problem?
javac should be in the bin directory of the java installation dir and java in the jre/bin directory. You could run dirname $(readlink -e $(which java)) to find out the absolute path to the jre/bin dir and then modify it to the bin dir. The result is added to your PATH variable in your ~/.profile.
Add this line to your ~/.profile (or ~/.bash_profile or ~/.bashrc, whichever is read on startup)
export PATH=$PATH:$(readlink -e $(dirname $(readlink -e $(which java)))/../../bin)
Then logout and login again and test if javac -version works as expected.
AFTER SETTING YOUR SYSTEM VARIABLE TO JAVA_HOME YOU NEED TO DO THIS FOR IT WORK ON YOUR COMMAND PROMPT:
After setting the JAVA_HOME system variable you need to also set the path so you can use javac from the command prompt:
After setting the JAVA_HOME system variable:
Inside System Variables find "Path" and click "Edit"
At the end of the Path add this line: ";%JAVA_HOME%\bin" (without the double quotes)
Now click "Ok" and exit out of your command prompt window (If it's still open)
now try "javac -version" and it should work
You can also check your java version, JRE build version, and Java Server VM build by typing "java -version"
Related
I have downloaded the jdk 1.8.0_131
when I open the command prompt and write the following command - java -version it gives me the output
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
but when I write the following command: javac -version it gives me the output
'javac' is not recognized as an internal or external command,
operable program or batch file.
I have edit the system variables path to - C:\Progra~1\Java\jdk1.8.0_131\bin;
and when I do the following command : "C:\Program Files\Java\jdk1.8.0_131\bin\javac" -version
it gives me the output:
javac 1.8.0_131
So i know I have installed the correct java version
I also checked the above folder and did find a javac.exe there. Please help.
Edit:
I finally solved the problem. What I was doing is editing the "Path" variable when what I had to do was make a new variable called "PATH" and the the following details :
Variable name : PATH
Variable value : c:\Program Files\Java\jdk1.8.0_xx\bin;[Existing Entries...
Have you tried restarting "cmd.exe" since adding the bin directory to your PATH?
If you confirm that your PATH includes the java bin directory and you can see the "javac.exe" binary in that location, then all should be set up correctly.
In Windows you need to add path to the jdk_your_version/bin to the PATH variable. Add this line to the PATH:
C:\Progra~1\Java\jdk1.8.0_131\bin;
Save it. Then restart CMD since it does not update the path automatically for the open cmd. Then you should be able to see that javac is working:
javac -version
I am trying to install Amazon Mturk command line tool on Ubuntu 13.10 ( 32-bit) system.
After setting the access secrete and access identifier in mturk.properties file, I ran the getBalance.sh file and below is the output.
./getBalance.sh
You must set JAVA_HOME (i.e. export JAVA_HOME=/usr)
If you do not have JAVA on your machine, you can download it from http://java.sun.com/
./../bin/invoke.sh: 41: exit: Illegal number: -1
The following is the java information on my system
$ file `which java javac`
/usr/bin/java: symbolic link to `/etc/alternatives/java'
/usr/bin/javac: symbolic link to `/etc/alternatives/javac'
My shell information is :
$ echo $SHELL
/bin/bash
But, $JAVA_HOME command gave me a blank line as result.
I can see the java installed on my machine :
$ which java
/usr/bin/java
$ java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1~0.13.10.1)
OpenJDK Server VM (build 24.51-b03, mixed mode)
Then I ran the following commands:
$ export JAVA_HOME=/usr/bin/java
$ echo $JAVA_HOME
/usr/bin/java
I thought everything is correct now, but here is what I get if I run the getBalnace.sh
$ ./getBalance.sh
./../bin/invoke.sh: 79: exec: /usr/bin/java/bin/java: not found
I checked my environment variables, below is the result
$ env | grep java
JAVA_HOME=/usr/bin/java
NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
And the path is:
$ echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/sid/.rvm/bin
I still could not figure out where am I doing wrong. The sentences below are quite confusing and no much information is available.
If you downloaded the Unix distribution, you must set the
MTURK_CMD_HOME environment variable to point to your Command Line
Tools installation location.
If you downloaded the Unix distribution, you must set the JAVA_HOME
environment variable to point to your Java Standard Edition Runtime
Environment (JRE) installation location.
Any help would be much appreciated.
In the Java world, JAVA_HOME refers to the directory where the JDK or JRE was installed. So you should be able to find the java executable at
$JAVA_HOME/bin/java
In your case, find the physical location where java is installed. Something like this should work:
readlink -f /usr/bin/javac
A typical response would be
/usr/lib/jvm/java-7-openjdk-amd64/bin/javac
For this response, you should set JAVA_HOME to
/usr/lib/jvm/java-7-openjdk-amd64
I want to run solR in mac OSX 10.9.1. So I installed JRE latest version. Then, I downloaded solR and expanded the folder. But when I try to run this jar file in example folder, I get this msg "no java runtime present", mentioned below.
Do I need to add JAVA_HOME env variable like we do in windows? If so, please tell me how.
Ananyas-MacBook-Pro:~ ananya$ /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build
1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
Ananyas-MacBook-Pro:~ ananya$ cd /Users/ananya/Desktop/VT\ study/solr-4.6.1/example
Ananyas-MacBook-Pro:example ananya$ java -jar start.jar
No Java runtime present, requesting install.
Ananyas-MacBook-Pro:example ananya$
Thanks.
"Do I need to add JAVA_HOME env variable like we do in windows?"
Test to see if/where Java is on your path in a terminal:
echo $JAVA_HOME
If the path to Java is wrong or missing you can add and Environmental Variable to ~/.bash_profile like so
JAVA_HOME=/usr/bin/java #or whatever your path is
export PATH=$PATH:$JAVA_HOME/bin/
You can open ~/.bash_profile in a terminal with nano
nano ~/.bash_profile.
Nano hint: writeout means save.
You'll need to reopen your terminal to load the new path. Or, reload it with the source command.
source ~/.bash_profile
Alternatively, if you like saving keystrokes you can type
. ~/.bash_profile
I'm trying to run Maven on cygwin. I've added maven to the path and my Java home looks like this:
$ echo $JAVA_HOME
/cygdrive/c/Program Files/Java/jdk1.6.0
Yet when I try to run mvn --version, I get this:
Error: JAVA_HOME is not defined correctly.
We cannot execute /cygdrive/c/Program Files/Java/jdk1.7.0_01/bin/java
Any idea why it's not working? Java -version works fine, so it's not a problem with java. I've also tried jdk1.6.0 instead.
Running which java gives,
$ which java
/cygdrive/c/windows/system32/java
and java -version gives,
$ java -version
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode, sharing)
If I run mvn.bat instead of mvn, I didn't have this problem.
So, since Cygwin will run the mvn file, I replaced this mvn file with a softlink (ln -s mvn.bat mvn) to the batch file. This way, running mvn will silently run the mvn.bat which handles these problems gracefully.
Anyone Using Cygwin and Maven, here's exactly what you need:
In your Cygwin bash prompt:
$ vim ~/.bashrc
or:
$ nano ~/.bashrc
(Which ever you fancy...)
Append the following:
alias mvn=mvn.bat
Save and Exit. Then run:
$ source ~/.bashrc
Now you should be able to use the mvn command as you do in cmd prompt.
Cygwin uses a dos console to execute Maven builds (mvn.bat).
Set your Java home to the C:\Program Files\Java\jdk1.7.0_01 location.
I was facing the same problem while running gradle from cygwin tool.
I used to set the Java home including the bin folder:
C:\Program Files\Java\jdk1.7.0_67\bin
But later I realized that some application do not recognize if you include bin folder, so I changed the class path to C:\Program Files\Java\jdk1.7.0_67 and it started working.
Setting JAVA_HOME to /cygdrive/c/Progra~1/Java/jdk1.6.0 might help.
I am having a problem opening uiautomatorviewer on mac.
This is what I get on the terminal when I issue the command uiautomatorviewer:
???#???-MacBook-Pro-2 libexec % uiautomatorviewer
SWT folder '/usr/local/Caskroom/android-sdk/4333796/tools/lib/
ERROR: JAVA_HOME is set to an invalid directory: /usr/libexec/java_home
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.' does not exist.
Please export ANDROID_SWT to point to the folder containing swt.jar for your platform.
Any suggestion?
You have not defined JAVA_HOME in your system path. To do this:
Open Terminal
Confirm you have JDK by typing “which java”. It should show something like /usr/bin/java.
Check you have the needed version of Java, by typing “java -version”.
JAVA_HOME is essentially the full path of the directory that contains a sub-directory named bin which in turn contains the java.
For Mac OSX – it is: /Library/Java/Home
Set JAVA_HOME using this command in Terminal: export JAVA_HOME=/Library/Java/Home
echo $JAVA_HOME on Terminal to confirm the path
You should now be able to run your application
Note that this sets JAVA_HOME only for this session. If you want it to persist, you will have to add the command to your ~/.profile file. Below are instructions on how to accomplish this instead:
Open up Terminal.app (Applications >> Utilities >> Terminal)
Type: emacs .profile
add this to the end of the .profile file:
JAVA_HOME=/Library/Java/Home
export JAVA_HOME;
Save and exit emacs (ctrl-x, ctrl-s; ctrl-x, ctrl-c)
Open a new Terminal window (cmd-n) and type: $JAVA_HOME/bin/java -version
If you see something like:
java version “1.8.0_16″
Java(TM) 2 Runtime Environment, Standard Edition (build 1.8.0_16-b06-284)
Java HotSpot(TM) Client VM (build 1.8.0_16-133, mixed mode, sharing)
Then you’ve successfully set your JAVA_HOME environment variable to the binary stored in /Library/Java/Home/bin/java
Source: SajeConsultants