Set custom Java version for CMake - java

I am trying to install a Tool (SciDB); its installing procedure makes use of CMake. At a certain point it requires Java 1.8, which is not installed on the system.
-- Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
CMake Error at src/jdbc/CMakeLists.txt:5 (message):
Java 1.8 is currently the only supported version for building JDBC!
I installed it somewhere in my home folder; how to tell CMake to use my version?
I tried to set the $JAVA_HOME and $PATH variable as suggested in this previous answer, but got no results.

SciDB uses its own version of FindJava.cmake (located in cmake/Modules/FindJava.cmake). SciDB expects a particular environment and that the user has installed OpenJDK version 1.8.
One way to use your JAVA_HOME is to modify cmake/Modules/FindJava.cmake in your source code and add your ${JAVA_HOME}/bin:
set(_JAVA_PATHS
$ENV{JAVA_HOME}/bin
/usr/lib/jvm/java-1.8.0-openjdk/bin
/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin
/usr/lib/jvm/java-1.8.0-openjdk.x86_64/bin
)
NOTE: The version of Java in that $JAVA_HOME will NOT be checked.

Related

How can I change Java version 1.7 to 1.8 in Ubuntu?

My Ubuntu machine have installed both java 1.7 and 1.8. But when I checked Java version it shows version Java 1.7 as the snapshot below. When I check Java alternative version I can see "java-8-openjdk-amd64". I am beginner to Ubuntu. Can anyone help me to change it to 1.8?
sdkman is a good Open source version manager for Java. It provides commands to search & install multiple versions of Java and switch between versions with
sdk use java 1.8.363-open
It can also manage other tools like Maven.
you can set the envirnoment variable to java 1.8
using this method
Edit the /etc/profile
sudo gedit /etc/profile
Add these lines in the end
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
like mentioned in this answer
How to set Java environment path in Ubuntu

Android Studio 3.4 build fails with openJDK

OS: Debian Stretch
Android Studio 3.4
JDK: open jdk 1.8
My Android studio build fails with following error:
Cannot find System Java Compiler. Ensure that you have installed a JDK
(not just a JRE) and configured your JAVA_HOME system variable to
point to the according directory.
I set JAVA_HOME, STUDIO_JDK etc and tried various tricks with openjdk , with no luck.
My default JRE is set to default as recommended
I am trying to update default JDK location as follow which given another error:
Already killed couple of hours to resolve this issue. So give android studio 3.4, my questions are:
What is wrong with the built-in compiler ?
Is openJDK 1.8 is valid jdk for android studio 3.4 to build/compile projects ? Or do I need Oracle-jdk?
I see oracle-jdk licensing has changed, can I use that for building commercial apps ?
Edit
I found later that the issue was , debian stretch installed jvm only. I tried to run javac -version which fails since by default stretch got jre only. Later I fixed by installing openjdk-8-jdk which fixed the issue:
sudo apt-get install openjdk-8-jdk
javac -version
javac 1.8.0_212
I had the same error and while i parsing google i found an interesting site.
In a lot of water i read the main information(in my opinion):
Android Studio requires Oracle Java 1.6 or later. It won’t work with OpenJDK.
I think we need to download oracle, becuase i see you are using java v 1.8 like me.
I didn't try that, but i think it will work.

Java classpath still the same after changing .bashrc

Is there a clear instruction available on how to set the classpath properly for updating the java jdk and the java vm?
On my system is Java 1.7 installed but I need the features of Java 8!
So I did the following steps as mentioned in the official Oracle classpath guide and other tutorials but it just doesn't work for me:
1.) moved the jdk to /usr/lib
2.) added the following lines to the ~/.bashrc:
PATH=/usr/lib/jdk1.8.0_60/bin:$PATH
export PATH
I type which java
Output is /usr/bin/java which is still the old 1.7 jdk
The runtime (VM) is not the official form Oracle but the openJDK so I also need to update this one to version 8...

OS X Yosemite not finding Java 8 runtime

I installed Java 8 SDK (with update 25 for JRE) from the Oracle Java site using the instructions on this page
http://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html
and put the following line in my ~/.bash_profile
export JAVA_HOME="/usr/libexec/java_home -v 1.8"
but when I try to compile or run a Java program in Bash I get the following message
No Java runtime present, requesting install.
and this window
I ran /usr/libexec/java_home to check:
$ /usr/libexec/java_home
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
But the JRE is in
/System/Library/Frameworks/JavaVM.framework/Versions/Current
and the JRE location in System Preferences is pointing to
/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin
I don't know what the problem is here, but usr/bin/javac and /usr/bin/java are not able to find the correct JVM location in /System/Library/Frameworks/JavaVM.framework/Versions/Current.
I have encountered the same problem , i think you should install JDK but not JRE
You need to add some backticks:
export JAVA_HOME="`/usr/libexec/java_home -v 1.8`"
The /usr/libexec/java_home command outputs the right value for JAVA_HOME on its standard output, you need to use backticks to capture that value so you can store it in the variable.
But the JRE is in /System/Library/Frameworks/JavaVM.framework/Versions/Current
No, it isn't. The Oracle JRE installs itself under /Library/Internet Plug-Ins, the Oracle JDK installs under /Library/Java/JavaVirtualMachines. The binaries under /usr/bin and /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands are stubs that delegate to whichever JDK your JAVA_HOME variable points to.
Here's how I solved my problem on my mac
Check from RStudio if Java_HOME has been setup properly by running Sys.getenv("JAVA_HOME") in the console. If it returns blank, you need to set it up properly
Check whether you have Java SDK installed
Open terminal and check if you have Java SDK installed
Run the /usr/libexec/java_home -vcommand. This will show you the library where you Java SDK is installed.
If you don't have Java SDK installed yet, result from command above is blank, or the version is not up-to-date, download here and install the latest version.
Copy the library shown in step 2. On my mac, it shows:
/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
Back on your RStudio console, set the JAVA_HOME
Sys.setenv(JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home")
After doing the steps above, h2o.init() ran without hitch.
Please carefully note #Ian Robert's point on JRE vs JDK distinction. We need JDK to make h2o run.
I've tried several solutions, downloading several sdk but Android Studio didn't recognize them as valid sdks.
Finally, the workaround that worked for me was:
Delete Android Studio.app and Android Studio preferences (~/Library/Preferences/AndroidStuido).
Rename /usr/libexec/java_home to java_home.bak.
Install again Android Stuido.
When Android Studio prompts for a valid Java SDK, follow link provided by Android Studio and download that java installation.
After installation, push detect button on Android Studio, and run.

java enum in different versions and updations

I am using jre 6 now. Earlier, I was using javasdk1.4 but as I searched in Internet, found that enum is supported in 1.5 or higher version. So, I first updated jre to latest version and then now how to update j2sdk1.4 .
When I am using echo %PATH%
path showed is "C:\Program Files\Java\jre7\bin"
But I can't set path to this location as 'javac' here is not recognizable..
My enum code i am not posting but is verified that it is correct.. Here, I am facing problem of setting path and updating j2sdk 1.4 even after jre updated to latest Version.
Note: I want to set path using command-prompt and Path command not using environment Variable.
I am using windows Xp
javac is not included in the JRE, it's just a runtime environment (Java Runtime Environment) used to run Java applications, nothing more.
Download a JDK (Java Development Kit) instead.

Categories