Javac on Ubuntu - java

I'm on windows 10 and running the bash shell (ubuntu), by turning the Windows Subsystem for linux on. Anyways, I'm trying to run some Java programs through the command prompt. I have already set the PATH variables and I can successfully run the java and javac commands in the windows command prompt. However, when I run the javac or java command using Ubuntu shell it says those commands are not found? So it lists some options that I can enter and one of those is
sudo apt install openjdk-8-jdk-headless
But when I run this command it says:
E: Unable to locate package openjdk-8-jdk-headless
I don't get it. I already have Java-8 installed and the PATH variables set, it works fine for the windows command prompt but fails to work with ubuntu. What am I doing wrong?
Thanks.

Do you have to use the OpenJDK version? Try this
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
See this link and this issue

Related

Java installation error in Ubuntu 18.4 LTS

I have to run Django CRM in my local machine. I followed all commands and tried to install every dependency.
I got stuck in the following command.
sudo apt-get install oracle-java8-installer -y java -version
I got the following error when I tried above command.
E: Command line option 'e' [from -version] is not understood in combination with the other options.
The link of Github CRM Django CRM
Documentation
Please someone help me.
Looking to Django-CRM documentation, seems like the command to install java (required by elasticsearch dependency) it's not the correct one for ubuntu 18.04
To install it you need to run:
apt-get install openjdk-8-jre-headless
Then you can follow the instructions as in the documentation
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch > key.elastic
apt-key add key.elastic
echo "deb https://packages.elastic.co/elasticsearch/2.x/debian stable main" | tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
apt-get update && apt-get install elasticsearch -y
Also, remember to add sudo on the commands if you are not running the commands as root

Installing and using rJava-dependent libraries on AWS EC2

I am using the machine image available here to host an RStudio server off of EC2 on which I will want to run analysis, in part using xlsx and rvest, both of which require Java and R to cooperate which they do not out of the box. I searched for a few solutions and tried to implement them, but got pretty much nowhere.
I SSH'd into the machine, and entered java -version and got this:
The program 'java' can be found in the following packages:
* default-jre
* gcj-5-jre-headless
* openjdk-8-jre-headless
* gcj-4.8-jre-headless
* gcj-4.9-jre-headless
* openjdk-9-jre-headless
Try: sudo apt install <selected package>
so I'm not sure what to do with that. I tried running sudo apt-get install r-cran-rjava which was also recommend on StackOverflow, and got this error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package r-cran-rjava
and likewise when I try to run sudo R CMD javareconf this is what I get:
*** JAVA_HOME is not a valid path, ignoring
*** Cannot find any Java interpreter
*** Please make sure 'java' is on your PATH or set JAVA_HOME correspondingly
I searched for Java it's stored here: java: /usr/share/java and I'm not sure how to set JAVA_HOME correctly, or how to set Java correctly.
What should I do?
Installing RJava (Ubuntu)
First, we need Java itself, check if it's installed
Write in Terminal: java -version
but you already checked it, so you need to install it.
If it returns The program java can be found in the following packages, then Java hasn't been installed yet, so execute the following command: sudo apt-get install default-jre. This will install the Java Runtime Environment (JRE).
Then Install JDK
Write in Terminal: sudo apt-get install default-jdk
Then assotiate the JDK installed with R
Run in Terminal: sudo R CMD javareconf
Install RJava and Rgdal
Execute: sudo apt-get install r-cran-rjava
Then: sudo apt-get install libgdal1-dev libproj-dev
Install package in RStudio
Run in RStudio: install.packages("rJava")
Done!

How to set java-7-oracle as default java version?

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
I tried to install oracle-java7 on my Linux Mint with the codes above. After executing those codes, I tried to check if its working by typing "java -version" but suddenly an error occured.
bash: /usr/bin/java: cannot execute binary file: Exec format error
You can install a package to set (and keep) oracle-java7 as the default; or you can manually set the java alternative with update-java-alternatives. Something like,
Option 1. sudo apt-get install oracle-java7-set-default
Option 2. sudo update-java-alternatives -s java-7-oracle

studio.sh command not found - Ubuntu

I am trying to get Android Studio running. I have installed jdk and jre
sudo apt-get install default-jre
sudo apt-get install default-jdk
I have set up my .bashrc and /etc/environment file to
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
but still nothing.
$JAVA_HOME returns correct value and so do java -version and whereis javac
What am I missing?
Following step worked for me
cd to YOUR_DIR_WHERE_ANDROID_STUDIO_TILL_BIN_FOLDER
then type command sh studio.sh or ./studio.sh
Try using sh ./studio.sh instead. Good luck.
Typing command sh studio.sh in the directory android-studio/bin, I solved this issue, so you ought to try this one instead as well.
It worked for me
-> Go to directory that has android studio bin.
-> Instead of using studio.sh use the command sh studio.sh
if you have installed android studio using jetbrains Toolbox then there is the path location
/home/username/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7678000/bin/

JDK not recognized after installation in Ubuntu 12.10

I did these steps without error:
JDK path :
Downloads/jdk-6u37-linux-x64.bin
Commands in Terminal:
mkdir Programs
cd Programs
bash ../Downloads/jdk-6u37-linux-x64.bin
ln -s jdk-6u37-linux-x64 jdk
Set JAVA_HOME and Path:
I added the following lines to the end of the .bashrc file:
export JAVA_HOME=$Home/Programs/jdk
export PATH=:$JAVA_HOME/bin:$PATH
This is the result of executing the command echo $JAVA_HOME:
/Programs/jdk
This is the result of executing the command echo $PATH:
:/Programs/jdk/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games1
And the problem is:
This is the result of executing the command
$ java -version
The program 'java' can be found in the following packages:
* default-jre
* gcj-4.6-jre-headless
* gcj-4.7-jre-headless
* openjdk-7-jre-headless
* openjdk-6-jre-headless
Try: sudo apt-get install
I think the problem is that environment variables are case sensitive in linux, so your
export JAVA_HOME=$Home/Programs/jdk
Should be
export JAVA_HOME=$HOME/Programs/jdk
In your echo $JAVA_HOME output you can see that you don't get your /home/yourname prepended...
Hope that helps.
Cheers,
The scripts located here will help you install sun's jdk on Ubuntu. Really useful stuff.
try this command
sudo update-alternatives --config java
This will list all the Java versions installed and configured.
If you see one or more installs, it will give you a list each element starting with a number. Just choose the number that corresponds to the version you want to use by default.

Categories

Resources