I've installed JRE 1.8 on MacOS X 10.10 from the official Oracle site. The file I've installed was jre-8u66-macosx-x64.dmg. To my surprise, the java command says I need JDK for it to work.
Is there a way to execute a jar from the command line on Mac without JDK? If not, what options for running Java code are there (other than browser applets)?
EDIT: when invoking java -v from the command line, I get the following output:
No Java runtime present, requesting install.
and an alert window, which says:
To use the "java" command-line tool you need to install a JDK.
One more data point: the folder /Library/Java/JavaVirtualMachines is empty. Instead, there's stuff under /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home. It even has a command-line java under /bin/. Running it with -version gives:
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
I wonder if I can somehow leverage that one for CLI..
Yes, Full Java functionality on the command line requires the SDK.
The SDK provides a Java install that includes OS-specific libs that are not included for the applet runner. I suppose some subset of Java apps and applets might run ok from the command line, but the applet plugin provides different services.
This has annoyed me for years, since now and again I need a Java environment, but most of the time would prefer to have no trace of it on my system. Even when I do have the browser plugin installed, it's usually disabled.
In the case a re-install does not fix the problem, you could set $JAVA_HOME to the location java is installed:
export JAVA_HOME=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
After that, java -v should work, but you'll have to do it for every new terminal window, or add it to .bash_profile or other file depending on the shell you use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With