ubuntu openjdk-7 the link "src.zip” is broken - java

I have installed OpenJDK 7 and it runs well on my Ubuntu 14.04 machine. I want to add Java sources to my Eclipse. When I go to /usr/lib/jvm/java-7-openjdk-amd64 there is a symlink called src.zip but it's broken. How do I fix this? Do I have to manually download sources and add them?

You should do:
sudo apt-get install openjdk-7-source
then the source code will be downloaded under: "/usr/lib/jvm/openjdk-7".
The symlink:
src.zip -> ../openjdk-7/src.zip
should work now.

The answer from Alex is correct, as in how it should be. However, for OpenJDK 11 on Ubuntu 18.10 it appears that src.zip has been moved to lib/src.zip so the symlink cannot be resolved.
In addition to the
sudo apt install openjdk-11-source
command, run
echo "(cd /usr/lib/jvm/openjdk-11/; ln -s lib/src.zip)" | sudo bash
to create an additional symbolic link.

I downloaded sources from http://jdk7src.sourceforge.net/ and added them to eclilpse. It works fine now.

installing openjdk8 again worked for me in ubuntu 16.04
step1: sudo apt install openjdk-8-source
step2 : attach the source.zip under(Window->preferences-java->Installed JREs->edit java-8-open-Jdk->expand rt.jar->click on Source attachment and attach the src.zip under /usr/lib/jvm/java-8-openjdk-amd64).

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 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.

Linux Ubuntu Android SDK manager not starting up - android:java: not found

I extracted the android SDK into a folder i made called "/usr/android/android-sdk-linux". I go into "tools/" and double click the executable file "android", click "Run in Terminal" but nothing happens. I also click "Run" but again nothing happens. i run it in terminal (./android command), and i get:
./android: 1: ./android: java: not found
./android: 1: ./android: java: not found
./android: 110: exec: java: not found
So why is this happening?
Edit: Here are the results of ~$ java
* default-jre
* gcj-4.6-jre-headless
* openjdk-6-jre-headless
* gcj-4.5-jre-headless
* openjdk-7-jre-headless
All i had to do was sudo apt-get install openjdk-7-jdk. Never trying a manual installation again. oh and sorry for my ignorance on the previous answers.
when you are using Debian based Linux Distribution, the better solution if you install JDK manually (not from repository) is by make a symbolic link that point to a java command.
I solved this problem. Create a symbolik link named /usr/bin/java dan point it to /home/your_name/your_jdk_folder/bin/java
This is the sample command in terminal/konsol
sudo ln -s /home/azware/tmp/jdk1.7.0_03/bin/java /usr/bin/java
Using Ubuntu 14.04 with Sun JDK 1.8 in /opt/jdk I solved this problem with this:
sudo update-alternatives --install /usr/local/bin/java java /opt/jdk/bin/java 0
sudo update-alternatives --install /usr/local/bin/javac javac /opt/jdk/bin/javac 0
This uses the Debian-based alternatives system that Ubuntu also uses. Please note that this is in the case that you don't have any other Java (i.e. OpenJDK) installed. If you have another Java installed, chances are you already have an alternative installed for it. Consult the update-alternatives man page to see how the system works.
It looks like you don't have java installed. Try just running java - is that not found?
Make sure that you have the Java6 JDK in particular, installed.
I was using android studio on ubuntu 14.04, 64bit and this error was caused due to the file permission issues in $home/android-studio/sdk/tools
$sudo chmod -R 755 ./*
Running the command in $home/android-studio/sdk/tools solved the problem.

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.

Can `apt-get install` be used for JDK?

I've been using a linux machine for less than two weeks, so I am extremely new to Linux.
I'd also like to install the Java Developers Kit. How should this be done? Is there an apt-get command, or should I just click on the download button at Sun's website?
I'm sure there is more than one way to do this, and it probably doesn't matter much, but I was impressed with how smoothly apt-get install worked when installing PHP and MySQL, so if there is a right way to do this, I'd like to know.
I'm using Ubuntu version 9.04
Yes, definitely it's the suggested way to install JDK on your Linux system (if available).
On Ubuntu:
sudo apt-get install sun-java6-jdk
The Oracle JDK is no longer included in the Ubuntu repos. According to https://stackoverflow.com/a/15543636/192221 , the following ppa can be used:
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java7-installer
If you have OpenJDK installed already, you might need to use
update-alternatives --config java
to use the Oracle Java by default.
If you for some reason need to install the sun packages you can use the make-jpkg command to create a deb file and still have the files managed by apt/dpkg.
To do this:
sudo apt-get install java-package
fakeroot make-jpkg jre-1_5_0_06-linux-i586.bin
you will then have a .dpg file that you can install using for example gdebi
gdebi-gtk jre.deb
Also note that you can have multiple JDKs installed and switch between them using update-alternatives:
update-alternatives --config java
update-alternatives --config javac
and so on for other java related binaries, have a look in /etc/alternatives to find out which are available.
In Ubuntu 9.10 Karmic Koala apt-get and the Synaptic Software Manager both install version 6.15.1 of Sun Java and the JDK, which are now out of date, and an old version of Netbeans,, so don't use "sudo apt-get install" for these.
Go to the Sun Java download page
http://www.java.com/en/download/manual.jsp
Select the non-RPM 32-bit or 64-bit self extracting file, download it and check the file size of the downloaded file. Doesn't matter where you download it.
Click on the link to installation instructions for the corresponding file.
An easier way to set executable permission is to right click on the file in the file browser (Nautilus) and click Properties, then on the Permissions tab, click the Execute checkbox.
To test, open a new terminal and type:
java -version
You should see Java version "1.6.0_18" etc.
If you don't, you probably need to add some lines, adjusted to suit your installation directories, to .bashrc and .bash_profile which are both hidden files in your home directory.
gedit .bashrc
Add the following:
export JAVA_HOME=/opt/java/64/jre1.6.0_18
export PATH=$PATH:$JAVA_HOME/bin
Then edit your .bash_profile file and insert the same lines at the end:
gedit .bash_profile
Open a new terminal window and test as above.
If all went well, in the Applications menu > System Tools, you should now have the Sun Java Control Panel.
You can repeat a similar installation procedure for the JDK and Netbeans where you mark the downloaded .bin file as executable and then execute it from a terminal window in the directory you want to install into, such as /usr/local.
After installing the JDK, add to your .bashrc and .bash_profile files a line similar to this:
export PATH=$PATH:/usr/local/jdk1.6.0_18/bin
Netbeans 6.8 seems to be able to set itself up ok without any editing and adds itself to the Applications Programming menu.
My Ubuntu box has sun-java5-jdk and sun-java6-jdk available.
I am personally a linux mint person. However, I couldn't find this in my respitory:
sudo apt-get install sun-java6-jdk
After poking around for a bit, I was able to get this to work.
sudo apt-get install openjdk-6-jdk
Cheers.
I'm not sure Ubuntu 9.04. Is it openJDK?
But in Ubuntu 9.10 It is openJDK.
So It have many problem.
You can do like this to remove and install sun java jdk
sudo apt-get remove openJDK*
sudo apt-get install sun-java6*

Categories