Unable to execute jshell from Mac Terminal - java

I am currently using java 1.8 on my Mac Sierra.
java -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
Now I want to run "jshell" for executing simple java commands right from the terminal. But I ended up with the following error message -
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/jshell" (-1)
What is the workaround do I need to do for avoiding this error message ?

As pointed out by #Elliott, you need to download and install Java-9 for working with jshell.
Once you have set the environment variable to make use of the /jdk../.../bin directory. You can execute the command jshell on your command line to get going.

Related

Java Home not define (wso2ei-6.4.0 installation)

I am trying to install wso2ei-6.4.0, but it will not run due to the following error messages. I am running a RPi with Debian
Error: JAVA_HOME is not defined correctly.
CARBON cannot execute java
I have executed Java -verison and have the following return
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode)
I know the java directory, using Java -which
/usr/bin/java
How do I run Java from any of the directory to execute the installation of wso2ei-6.4.0?
After some time and reading, I managed to add the following into ~/.bashrc:
export JAVA_HOME="/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt"
export PATH=$PATH:$JAVA_HOME/bin
Note the arm32 directory for the jdk
Try this (as root user):
export JAVA_HOME=/usr/bin/java
Does this solve your issue?

What is my real Java version on macOS?

I use macOS Sierra. When I do:
java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468-11M4833)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)
it seems that my java version is 1.6.0.
But when I look at System Preferences I find that my version is Java 8 Update 144. I want to use an R package that needs Java >=8.0. What have I done wrong?
The Java found in your command line is the one used to compile when using command line, first, try export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) then check if the correct version shows up using java -version if not reinstall the newest java and run the command again

Apache not aware of window path variables?

I am trying to do the same as this guy. I want to be able to get a result when I do this:
$javaExec = shell_exec('java -version 2>&1');
var_dump($javaExec);
However, all I get is:
'java' is not recognized as an internal or external command,
operable program or batch file.
If I run "java -version" from the command line (i.e. cmd), I get:
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
But I can't get PHP/Apache to get the same result. Is there something I need to do to make Apache aware of the path environment variables?
I tried restarting Apache and my PC, but unfortunately no luck. Any ideas?

Ignore Java.exe from Path and use the one from directory I am in

I setup Java 6 to be used by all other application. Normal setup with JAVA_HOME, JRE_HOME, etc. This is working fine.
I have another application that needs Java 7. I downloaded Java 7.exe and extraced tools.zip from it to a folder. Now I am trying to check the version going to the bin folder. When I type in java -version, I get the following error.
error occurred during initialization of vm
java/lang/noclassdeffounderror java/lang/object
where as java -fullversion shows Java 7. It looks like even though I am in the bin folder where Java.exe exists, it still getting the one from PATH?!?!
How do I use the java.exe from a folder ignoring the one from PATH?
You need much more than java to run java. You need all the rt.jar and lib which come with Java. It sounds like you are missing some part of the JRE or it can't find your JRE.
I suggest you re-install the version you need and run it using the full path name like
c:\>"c:\Program Files\Java\jdk1.7.0_60\bin\java" -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
c:\>"c:\Program Files\Java\jdk1.8.0_45\bin\java" -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
By using the full path name you can use any specific version from any directory.

maven2 on ubuntu java home is not defined correctly

I have problem to use maven from ubuntu server 13.10 64bit.
I am getting following error (even when I type mvn -version):
Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/lib/jvm/jdk//bin/java
But when I type java -version I get:
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)
I have no idea where can be the problem, especially because I have used maven without any problems before I've installed hadoop 2.2.
Thank you in advance for any help.
It appears that the Hadoop instructions and/or start up script modifies the JAVA_HOME environment variable in the shell.
Unless this change is made permanent by changing one of the many configuration files - like $HOME/.profile - it only influences the shell in which you have observed the problem.

Categories

Resources