How to Set Java Home for Notebook in SageMaker - java

So it seems that I have Java installed after running the below line in the SageMaker Notebook Terminal:
bash-4.2$ sudo yum install java-1.8.0-openjdk
In the terminal I write the following to confirm:
bash-4.2$ java -version
java version "1.7.0_261" OpenJDK Runtime Environment (amzn-2.6.22.1.83.amzn1-x86_64 u261-b02) OpenJDK 64-Bit Server VM (build 24.261-b02, mixed mode)
In my notebook I have the following Lines of code:
import tabula
tabula.environment_info()
The notebook results in an error with:
java -version` faild. `java` command is not found from this Pythonprocess. Please ensure Java is installed and PATH is set for `java`
Yet, in the terminal I see this:
bash-4.2$ java -version
java version "1.7.0_261" OpenJDK Runtime Environment (amzn-2.6.22.1.83.amzn1-x86_64 u261-b02) OpenJDK 64-Bit Server VM (build 24.261-b02, mixed mode)
I definitely have a java environment. How can I set my notebook to find this?

One approach is to install it from sagemaker notebook via !sudo yum install ...
You can verify the path in the notebook to confirm the linking

Related

centos using older version of java

I want to install open office in my centos linux and as part of the requirement is jdk 11.0.2 version.
I installed new version of java JDK 11.0.2 however when I use the command java -version it is still showing that it is using old version of java.
java -version
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
i created the file /etc/profile.d/jdk11.sh and ran the command below
"source /etc/profile.d/jdk11.sh"
the file contains
export JAVA_HOME=/usr/local/jdk-11.0.2
export PATH=$PATH:$JAVA_HOME/bin
Given that you are using centOS:
try the following command:
sudo update-alternatives --config java
It should show you the list of available Java versions in your system. You can switch using the numbers shown in the result of the command.

Update Java version in Windows 10 WSL

I had openjdk 11.0.2 installed. I upgraded the java version by running
sudo apt update
sudo apt install openjdk-11-jdk
If I run sudo apt install openjdk-11-jdk again, it shows a message saying that "openjdk-11-jdk is already the newest version (11.0.11+9-0ubuntu2~20.04)"
However, when I do java -version it displays the older version 11.0.2 not 11.0.11
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
The JAVA_HOME still shows "/opt/java/jdk-11.0.2", so I guess this might be the problem that the java -version is still showing the older version?
When I do whereis java it shows
java: /usr/bin/java /usr/share/java /opt/java/jdk-11.0.2/bin/java /mnt/c/Program Files/Common Files/Oracle/Java/javapath_target_917640/java.exe /usr/share/man/man1/java.1.gz
Not sure where the newest version was installed so that I can make the JAVA_HOME point to that one
openjdk-11-jdk-headless_11.0.11+9-0ubuntu2~20.04_amd64.deb and openjdk-11-jre-headless_11.0.11+9-0ubuntu2~20.04_amd64.deb package shows (by extracting with 7-zip) that OpenJDK 11 will be installed at /usr/lib/jvm/java-11-openjdk-amd64.
This will give you enough information about appending environment variables such as PATH and JAVA_PATH.
And, there may be a path called default-jvm or so, you may use that path accordingly.

How to verify that the YourKit agent is installed properly on macOS using terminal with JDK 1.8+

I would like to verify that I have installed YourKit agent properly and I have it on my PATH.
I am using:
macOS 10.14.4
java version "1.8.0_191"
Any thoughts how to verify that using the terminal.
Please try to run "java -agentpath=full_path_to_libyjpagent.jnilib -version" command. If all is OK, you will see YourKit Java Profiler agent output together with the output of "java -version".
The output should look like:
[YourKit Java Profiler 2019.1-b113] Log file: /home/xxxx/.yjp/log/java-6519.log
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.18.10.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
More details is here https://www.yourkit.com/docs/java/help/agent.jsp

`java.lang.ClassNotFoundException: javax.media.jai.ImageLayout` error

I was running a geoscript-groovy tutorial code:
groovy:000> import geoscript.layer.GeoTIFF
groovy:000> format = new GeoTIFF()
groovy:000> raster = format.read(new File("raster.tif"))
, and got the follow errors:
ERROR java.lang.NoClassDefFoundError:
javax/media/jai/ImageLayout
I have limited knowledge about JAI. I don't know whether this is a general JDK configuration issue or an issue with groovy etc.
My questions are:
What's the cause of this error associated with javax.media.jai.ImageLayout and how to fix it?
How do I verify if javax.media.jai.ImageLayout is really installed.
Thanks
P.S. The software environment is Ubuntu 12.04 with:
$java -version
java version "1.6.0_32"
OpenJDK Runtime Environment (IcedTea6 1.13.4) (6b32-1.13.4-4ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
$groovy -v
Groovy Version: 1.8.6 JVM: 1.6.0_32 Vendor: Sun Microsystems Inc. OS: Linux
-- UPDATE --
I changed JDK to oracle
$ java -version
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)
and still I am getting the following error:
ERROR java.lang.NoClassDefFoundError:
javax/media/jai/ImageLayout
at org.geotools.gce.geotiff.GeoTiffFormat.getReader (GeoTiffFormat.java:287)
at org.geotools.gce.geotiff.GeoTiffFormat$getReader.call (Unknown Source)
Also, the commands I used to install Oracle JDK are:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
I also did
sudo apt-get install libjai-core-java libjai-imageio-core-java
and I am still getting the same error.
To use javax.media.jai.ImageLayout you need an Oracle JDK. It's not present in OpenJDK. I don't know the library you're using so I can't tell you if there is any option to e.g. inject different strategy for image manipulation. Switch to Oracle JDK and test if it works for you that way.

jmxtrans - Cannot execute

I am trying to get jmxtrans to work yet I get the below on ubuntu 12.04 and using openjdk 7.
/usr/share/jmxtrans# java -version
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
/usr/share/jmxtrans# ./jmxtrans.sh start /var/lib/jmxtrans/kafka.json
Cannot execute /usr/lib/jvm/default-java/bin/jps -l!
What does the above mean?
It seems that the jps file can't be found in the /usr/lib/jvm/default-java/bin directory. It is available in the '-devel' packages if you want to install those (yum install java-1.7.0-openjdk-devel, apt-get install openjdk-7-jre-devel). It could also be that your JAVA_HOME is not pointing to the correct place if you have multiple java versions installed.
You should not need it however, regular ps works fine. You can add a variable to your configuration that says export USE_JPS=false. The configuration can be found in /etc/default/jmxtrans.
Check out these issues for more information:
https://github.com/jmxtrans/jmxtrans/issues/89
https://github.com/jmxtrans/jmxtrans/pull/109

Categories

Resources