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?
Related
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?
I am using Mac os Sierra 10.12.3 ,I want to execute the byte code on the Java(TM) Virtual Machine
(JVM) I need to set the CLASSPATH,
Using my terminal
CLASSPATH=</Users/.../Documents/jj2000/jj2000-4.1\ 3>/jj2000-4.1.jar:$CLASSPATH export CLASSPATH
show me
-bash: /jj2000-4.1.jar:: Permission denied
I am confusing with command line how can I set the CLASSPATH.
My java is
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b20)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b20, mixed mode)
Please help.
Don't, ever, set a global CLASSPATH environment variable. Pass the classpath to each java program you launch: each one has its own, specific classpath.
java -cp /path/to/jj2000-4.1.jar:your-application.jar com.yourcompany.youapp.Main
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.
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.
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.