Java default packages - java

I write a small java program to read file and do the string matching in windows 8 by using net beans. But when i compile it on ubuntu by using terminal following message appeared. Is there any default packages in ubuntu , for following packages in the error.
The program 'javac' can be found in the following packages:
* default-jdk
* ecj
* gcj-4.6-jdk
* gcj-4.7-jdk
* openjdk-7-jdk
* openjdk-6-jdk
Try: sudo apt-get install <selected package>
ucsc#ucsc-VirtualBox:~/Desktop/Question$

You do not have javac, the java compiler installed. Follow the recommendation given - install one from the variations offered. I'd suggest openjdk-7-jdk.

You don't have a java compiler installed (javac). Use 'sudo apt-get install openjdk-7-jdk' to install it.

You don't have a JDK installed on your ubuntu system so the javac command to compile your program doesn't exist. Just run the command like it says to install something that has it. I would go with defualt-jdk since I assume that Ubuntu would know to download the Java8 packages in an update when they are switched to be the default while the openjdk ones will not.
sudo apt-get install default-jdk

Related

Install webstorm but no jdk found on ubuntu 14.04LTS

I am trying to install webstorm, but when I try to run the *.sh file it gives me error of not having java environment available.
So I tried to look into the official documentation
But the steps to install the jdk didn't worked. I tried to locate java folder, but couldn't locate this directory /usr/bin/java
Please guide me how I can install webstorm now?
Java generally installs in /usr/lib/jvm/java-[major version]-openjdk-[arch]. Install a package such as openjdk-7-jdk and check in that location.
If you already have java installed, running which java will tell you the path of the java executable.
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
I haven't tried with java-8. Then:
sudo update-alternatives --java
And set auto-mode or java-7 (You might try with java-8)
First check the about java version
java -version
if its not returning you need to check your installed jdk
go to
cd /usr/lib/jvm
if you are finding something which start with java_XXXX
it means this is the only your jdk, and you can set JAVA_HOME as well path till bin folder by using export
I had a similar problem, during installation of eclipse (openjdk-7-jdk was required). I used
> sudo apt-get update
> sudo apt-get install ...
and it worked.
You should just install a JRE (to allow Java execution programs) and not a JDK (to develop Java programs).
No need a JDK to allow Webstorm to lauch.
On ubuntu : apt-get install default-jre
Have a nice day :)
David

How to compile and run .java files in ubuntu?

I have Ubuntu 13.04 32-bit installed on my system.
I downloaded Java SE Development Kit 7 from here with the extention .tar.gz
I used the command tar xvfz Downloads/jdk-7u51-linux-i586.tar.gz to uncompress the downloaded file in my home directory i.e /home/computer/
I am able to compile and run java program using Bluej IDE. It is working fine.
I used the command jdk1.7.0_51/bin/java -jar Downloads/bluej-310.jar to install bluej IDE.
But I also want to compile and run java programs using the terminal in Ubuntu.
When I type the command java -version I get the message
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 <selected package>
Can anyone please help me out.
You can either install openjdk-7-jdk or add the bin directory of your downloaded distribution to your PATH variable and make it permanent by doing it in the configuration file of your shell. (Most likely .bash_profile in your home directory).
The easiest is probably sudo apt-get install openjdk-7-jdk (and then you can delete the one you downloaded).
I suggest that follow the instructions on https://help.ubuntu.com/community/Java. I think it's a lot more easier if you focused on the section regarding openjdk than sections on oracle java 7 than IBM 4. You may use the ubuntu software center app to locate the packages and install them rather than using the terminal.
You haven't completely installed java.. You are attempting to run the bash command
$java
and wherever you have extracted the jre, it isn't in your $PATH...
You must add it to your path like so:
$export PATH=$PATH:/home/computer/%THE_JAVA_DIR_THAT_YOU_INSTALLED%
or better yet,
get rid of the stuff you extracted and do this:
$sudo apt-get install openjdk-6-jre
It can save you a bit of a hassle to use Ubuntu's apt-get to install programs whenever possible
================EDIT
if ~/.profile doesn't exist, create it
Add the following lines in your .profile file in your home directory (using vi ~/.profile):
PATH=$PATH:/home/me/play
export PATH
Then, for the change to take effect, simply type in your terminal:
$ . ~/.profile

The full pathname of a JDK installation for Oracle SQL Developer

I want to run Oracle SQL Devloper on Ubuntu with this command:
sh sqldeveloper/sqldeveloper.sh
Then I got this message:
Type the full pathname of a JDK installation (or Ctrl-C to quit), the
path will be stored in /home/aimad/.sqldeveloper/4.0.0/product.conf
So I gave the path of jdk as the following:
/usr/lib/jvm/java-7-openjdk-i386/
But then I got this message:
Error: Java home /usr/lib/jvm/java-7-openjdk-i386//bin/java is not a
JDK. Running SQL Developer under a JRE is not supported.
For me it was similar error. I solved it simply by inserting
SetJavaHome /usr/lib/jvm/java-7-openjdk-amd64/
into ~/.sqldeveloper/4.0.0/product.conf file.
I Agree with szabozoltan's answer but there should be some explanation required for this:
SetJavaHome /usr/lib/jvm/java-7-openjdk-amd64/
This one we need to keep in product.conf file. Inorder to open that file we need to type following command:
sudo gedit /home/abc/.sqldeveloper/4.0.0/product.conf
After this, type the following command.
./sqldeveloper.sh
That's it, your SQL Developer
will be opened.
You only have the Java JRE installed, you need to install the JDK in order for Oracle SQL Devloper to work.
TL;DR
Install the JDK, type sudo apt-get install openjdk-7-jdk in a terminal.
Checking if JDK is Installed
To check if you have the JDK installed, type aptitude search openjdk-7-jdk in the terminal. If you see an i beside either package then it is installed. For example, I have the 64-bit JDK installed on my machine, this is the output.
$ aptitude search openjdk-7-jdk
i openjdk-7-jdk - OpenJDK Development Kit (JDK)
p openjdk-7-jdk:i386 - OpenJDK Development Kit (JDK)
If the package does not have an i beside it, then it is not installed.
Installing JDK
To install in the JDK in ubuntu you need to install the package openjdk-7-jdk. Install by running sudo apt-get install openjdk-7-jdk in a terminal.
Setting JAVA_HOME
After installing the JDK you need to set the JAVA_HOME environment variable.
You can see all the installed JDKs on your machine by running update-java-alternatives -l, choose the one you want to use and copy the third field, this field is the JAVA_HOME for that JDK.
For example, on my machine
$ update-java-alternatives -l
java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64
This means I only have one JDK installed, java-1.7.0-openjdk-amd64, and its JAVA_HOME is /usr/lib/jvm/java-1.7.0-openjdk-amd64.
Next, set the JAVA_HOME environment variable, in Bash I would set it by running this from the terminal:
$ export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
Check to make sure it was set correctly.
$ echo $JAVA_HOME
/usr/lib/jvm/java-1.7.0-openjdk-amd64
This will set JAVA_HOME for your current terminal session, to not have to worry about setting it again, you can add it to your ~/.bashrc file.
Running Oracle SQL Developer
Once the JDK is installed and the JAVA_HOME environment variable set, you can move into the sql developer directory and run the sqldeveloper.sh script.
$ cd sqldeveloper
$ ./sqldeveloper.sh
If sqldeveloper.sh is not executable run chmod +x sqldeveloper.sh and run the script again.
Checking all Java packages
For completeness, you can check what Java packages you have installed by running aptitude search openjdk-7. If you have the JRE installed you will se an i beside a package that begins with openjdk-7-jre
$ aptitude search openjdk-7
p openjdk-7-dbg - Java runtime based on OpenJDK (debugging symbols)
p openjdk-7-dbg:i386 - Java runtime based on OpenJDK (debugging symbols)
p openjdk-7-demo - Java runtime based on OpenJDK (demos and examples)
p openjdk-7-demo:i386 - Java runtime based on OpenJDK (demos and examples)
p openjdk-7-doc - OpenJDK Development Kit (JDK) documentation
i openjdk-7-jdk - OpenJDK Development Kit (JDK)
p openjdk-7-jdk:i386 - OpenJDK Development Kit (JDK)
i openjdk-7-jre - OpenJDK Java runtime, using Hotspot JIT
p openjdk-7-jre:i386 - OpenJDK Java runtime, using Hotspot JIT
i openjdk-7-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
p openjdk-7-jre-headless:i386 - OpenJDK Java runtime, using Hotspot JIT (headless)
i openjdk-7-jre-lib - OpenJDK Java runtime (architecture independent libraries)
v openjdk-7-jre-lib:i386 -
p openjdk-7-jre-zero - Alternative JVM for OpenJDK, using Zero/Shark
p openjdk-7-jre-zero:i386 - Alternative JVM for OpenJDK, using Zero/Shark
p openjdk-7-source - OpenJDK Development Kit (JDK) source files
p uwsgi-plugin-jvm-openjdk-7 - Java plugin for uWSGI (OpenJDK 7)
p uwsgi-plugin-jvm-openjdk-7:i386 - Java plugin for uWSGI (OpenJDK 7)
p uwsgi-plugin-jwsgi-openjdk-7 - JWSGI plugin for uWSGI (OpenJDK 7)
p uwsgi-plugin-jwsgi-openjdk-7:i386 - JWSGI plugin for uWSGI (OpenJDK 7)
Just solved this by not adding slash as you did, so instead of
/usr/lib/jvm/java-7-openjdk-i386/
type
/usr/lib/jvm/java-7-openjdk-i386
Just type /usr/java/default and hit Enter if you use Oracle's JDK.
Just insert below one into ~/.sqldeveloper/4.0.0/product.conf file.
SetJavaHome /usr/lib/jvm/java-7-openjdk-amd64/
I had a similar issue and solved it by simply adding 'SetSkipJ2SDKCheck true'
to one of the below files.
/home/abc/.sqldeveloper/4.1.5/product.conf
/opt/sqldeveloper/sqldeveloper/bin/sqldeveloper.conf
In my case (Oracle SQL Developer 4.1.3) it seems to be problem with Java version - when I point to Java 8 JDK instead of 11, it started working immediately.
I've faced with similar issue. Tried published recommendations but unsuccessfully. Possible the reason I'm using sdkman to manage java versions, may be something with permissions because of Mac OS.
For Mac user it is important try manage configuration:
try SetJavaHome {{path to your java}} in ~/.sqldeveloper/{{sql-dev-version}}/product.conf
this step could help if you are using jdk installed by brew following default path.
If you've installed openjdk with sdkman path to java will be like ~/.sdkman/candidates/java/{{java-version}} and this path needs to be mapped on default expectations with aliases.
I did not have information about the default path, so it needs to find executable file:
start sqldeveloper (to make shown error message);
in terminal try ps ux | grep sql - it will help you to detect executable file location sqldeveloper.sh;
open the file with text editor:
remove or comment block that tries to get java from default location /usr/libexec/java_home;
find line with export JAVA_HOME=$TMP_PATH and replace path with your path to java home or simply remove line if JAVA_HOME was specified in OS settings.
In newer version I needed to extend the path in
/Users/{{yourUsername}}/.sqldeveloper/21.2.1/product.conf
SetJavaHome /Library/Java/JavaVirtualMachines/jdk-11.0.13.jdk/Contents/Home
apt-get install openjdk-6-jre
apt-get install openjdk-7-jre
apt-get install openjdk-6-jdk
apt-get install openjdk-7-jdk
add-apt-repository ppa:webupd8team/java
apt-get update
apt-get install oracle-java7-installer

How can I install Eclipse and Java SDK on Ubuntu?

I have just downloaded Ubuntu. It runs much faster than my Windows XP. But, I don't know how I can set up Eclipse v4.2 (Juno), or the Java SDK. I am currently developing in the Lightweight Java Game Library, so I might need some help with that too.
Execute this in your terminal:
sudo apt-get install eclipse
sudo apt-get install openjdk-6-jdk openjdk-6-source openjdk-6-demo openjdk-6-doc openjdk-6-jre-headless openjdk-6-jre-lib
The first one installs Eclipse (you will be asked to enter your password), and the second one installs all the Java stuff you may need!
Don't install Eclipse from the Linux repositories. These repositories may not be up-to-date with the last versions released by Eclipse. A better approach is to follow the instructions in this answer from Ask Ubuntu. For Java programming, make sure you have a JDK and a JRE installed
apt-get install openjdk-7-jdk openjdk-7-jre
You can download whatever Eclipse Java IDE version suits you best from the Eclipse website (link to the Eclipse v4.4 (Luna) release).
You might want to consider installing Sun Java 6 for your Java programming needs; correct me if I'm wrong, but I feel that OpenJDK may still be lacking in some libraries and compatibilities.
If you want to install Java 6 on your machine, you can follow this guide on how to do so: https://codingforme.wordpress.com/2012/05/14/installing-oracle-java-jdk-6-or-7-on-ubuntu-12-04/
Java installation on Ubuntu:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
Eclipse IDE installation on Ubuntu:
Since it requires a detailed list of steps, I would suggest you to visit the blog post Install Eclipse IDE Mars in Linux Ubuntu to check out steps to install Eclipse on Linux Ubuntu.
You don't really install Eclipse - you just download the folder and run the program - just like in windows. Just make sure you download a Linux version.
To install JDK, type:
sudo apt-get install openjdk-6-jdk
You will be asked to type in your password before the installation will begin. You could also install JDK through the software manager.
Just remove all Eclipse packages typing:
sudo apt-get autoremove eclipse
And with tab find all installed Eclipse packages.
Do the same with Java.
I just reinstalled Eclipse with the command
sudo apt-get install eclipse
which also contains Java.

javac : command not found

I have installed java in my CentOS release 5.5 machine using the command yum install java. But I am unable to compile a class using javac.
Do I need to install any other package?
I have tried to locate the javac executable but i am unable to locate it.
/usr/bin/java is linked as follows:
/usr/bin/java -> /etc/alternatives/java
/etc/alternatives/java -> /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
I have seen the following output by yum list installed |grep java:
java-1.6.0-openjdk.x86_64 1:1.6.0.0-1.16.b17.el5 installed
tzdata-java.x86_64 2011b-1.el5 installed
Worked for me with this command:
yum install java-devel
You installed the Java Runtime Environment (JRE) only, which does not provide javac. For javac, you have to install the OpenJDK Development Environment. You can install java-devel or java-11-devel, which both include javac.
By the way: you can find out which package provides javac with a yum search, e.g.
su -c 'yum provides javac'
on more recent releases of CentOS e.g. 6 the command changes to
su -c 'yum provides */javac'
Use the following sudo command:
sudo yum install java-1.6.0-openjdk-devel
I don't know exactly what yum install java will actually install. But to check for javac existence do:
> updatedb
> locate javac
preferably as root. If it's not there you've probably only installed the Java runtime (JRE) and not the Java Development Kit (JDK). You're best off getting this from the Oracle site: as the Linux repos may be slightly behind with latest versions and also they seem to only supply the open-jdk as opposed to the Oracle/Sun one, which I would prefer given the choice.
I use Fedora (currently 31)
Even with JDK's installed, I still need to specify JAVAC_HOME in the .bashrc, especially since I have 4 Java versions using sudo alternatives --configure java to switch between them.
To find java location of java selected in alternatives
readlink -f $(which java)
In my case:
/usr/java/jdk1.8.0_241-amd64/jre/bin/java
So I set following in .bashrc to:
export JAVA_HOME=/usr/java/jdk1.8.0_241-amd64/jre/bin/java
export JAVAC_HOME=/usr/java/jdk1.8.0_241-amd64/bin/javac
export PATH=$PATH:/usr/java/jdk1.8.0_241-amd64/jre/bin
export PATH=$PATH:/usr/java/jdk1.8.0_241-amd64/bin/
Now javac –version gives:
javac 1.8.0_241
This is useful for those who want to use Oracle's version. Just remember to change your .bashrc again if you make a change with java alternatives.
Is the javac executable in a directory that is part of your PATH?
I don't know the CentOS equivalent of the Windows path but if you cd to the java sdk directory and run ./javac does anything happen?
Install same version javac as your JRE
yum install java-devel
This worked for me:
sudo dnf install java-<version>-devel
You have installed the Java Runtime Environment(JRE) but it doesn't contain javac.
So on the terminal get access to the root user sudo -i and enter the password.
Type yum install java-devel, hence it will install packages of javac in fedora.
Linux Mint 19.3
I installed Java Oracle manually, like this:
$ sudo ln -s /usr/lib/jvm/java-1.8.0_211/bin/javac /usr/bin/javac
for java 8 use
sudo yum install java-1.8.0-openjdk-devel
Make sure you install JDK/JRE first.
follow these steps:
open terminal go to your root dictionary by typing
cd /
you will see Library folder
Now follow this path Library/Java/JVM/bin
Once you get into bin you can see the javac file
Now you need to get the path of this folder for that just write this command
pwd
get the path for your javac.

Categories