I want to use Stanford CoreNLP in my Google Colab Notebook. For that I need Java. Is there a way to install Java on those machines?
What I currently have is:
!pip install StanfordCoreNLP
from stanfordcorenlp import StanfordCoreNLP
nlp = StanfordCoreNLP('stanford-corenlp', lang='de', memory='4g')
...
nlp.close()
and I get the error:
FileNotFoundError: [Errno 2] No such file or directory: 'java': 'java'
Although geared and promoted predominantly as a tool for writing Python, adding a Java Kernel to Google Colab is actually pretty simple. Below is an example, using IJava. Assuming you know how to create a new account, and can navigate creating a new notebook… Edit the '.
The Basics. Colaboratory, or “Colab” for short, is a product from Google Research. Colab allows anybody to write and execute arbitrary python code through the browser, and is especially well suited to machine learning, data analysis and education.
Jupyter notebooks are extremely popular in the Python world, simply because it is great to combine documentation and code in a visually appealing way. Great tool for teaching! Thanks to the IJava kernel and the JDK 9+ JShell feature, it is possible to run Java within Notebooks without compiling the code now as well.
To run the code in any cell, you can click the run button on the left side of the code cell (looks like a “play” button with a triangle in a circle) or you can click [shift] + [enter]. The output will appear right below the code cell. You can import many popular libraries without having to install them first.
Because your system's configurations don't matter AT ALL! With Colab, you can train your complex machine learning and deep learning models without worrying about the computational resources they require. GPUs and even much more expensive TPUs are provided by the platform free of cost!
try this
import os #importing os to set environment variable
def install_java():
!apt-get install -y openjdk-8-jdk-headless -qq > /dev/null #install openjdk
os.environ["JAVA_HOME"] = "/usr/lib/jvm/java-8-openjdk-amd64" #set environment variable
!java -version #check java version
install_java()
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