I was initially using vs-code where everything was working.
I think eclipse doesnt understand I am using lombok, so I downloaded lombok.jar from here
while trying to run java -jar lombok.jar i get the following error -
eclipse -
java version and paths
the issue, as pointed out by #stdunbar was conflicting versions
i was initially trying
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-16.0.1/bin/java 1
but it didnt work. what worked was
sudo update-alternatives --config java
i selected /usr/lib/jvm/jdk-16.0.1/bin/java there, and now it works
Just ensure that your JAVA_HOME and java -version point to the same Java. For that make sure you have updated JAVA_HOME variable in "/etc/profile" or "/etc/environment" or "~/.bashrc", all these files should be updated if they point to different JAVA folders.
Related
I am using Manjaro GNU/Linux 5.7.0-3 x86_64 and had installed older Java Oracle jdk1.8 previously but now I want to install Oracle jdk14.0.1 which I have unpacked to /opt.
In order to reflect the changes, I edited ~/.bashrc file by adding this line:
export PATH="/home/arjun/anaconda3/condabin:/home/arjun/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/jdk-14.0.1/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl"
Then executed these to reload the terminal:
source ~/.bashrc
bash;
And I even restarted the computer but still, Java is using the older version:
$ javac -version
javac 1.8.0_252
What's going wrong?
Thanks!
In ArchLinux and manjaro you can use pre-installed archlinux-java utility.
for getting information about all installed java's and current choice, you need status and for change it you can use set
sudo archlinux-java status
sudo archlinux-java set java-14-jdk # or something similar related to java14
read more about it in the wiki
Because of different versions of java are installed, you can change default option with this command.
sudo update-alternatives --config java
With this command, you can select java version as default option.
I have installed JDK 1.8 on my ubuntu 16.04, for some kind of work I had to install JDK 1.7.I installed it without did anything to my older version and changed the $JAVA_HOME to point the newly installed location.
echo $JAVA_HOME works fine , showing newly installed version which is 1.7
but when I do $ java -version it shows earlier installed version which is 1.8.
Why does this happen? How to resolve it.
I need 1.7 to work with it further.
If I went wrong in somewhere please correct me,I need good explanation regarding this.
Thank you.
here is my terminal
Try to run following command in terminal:
$ sudo update-alternatives --config java
It shows installed alternatives for java command. You can choose which one you will use by default further on.
I have a machine running RHEL 6. Currently JDK 7 is installed. For ElasticSearch I need to move to JDK 8. SO i copied the JDK 1.8 to /opt/. THen ran the below steps.
update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_45/bin/java 100
update-alternatives --config java
Did the same thing for Javac as well.
Then did the below changes to Environment variables
export JAVA_HOME=/opt/jdk1.8.0_45/
export PATH=/opt/jdk1.8.0_45/bin:...
In setting path, i copied the existing path, removed the jdk7 entries and added the entire path again.
After this when i ran java -version i got 8. But on restarting the shell, it reverted back to 1.7!!!
So i checked internet and found that i need to update the /etc/profile file
So added below two entries..
export JAVA_HOME=/opt/jdk1.8.0_66/
export PATH=/opt/jdk1.8.0_66/bin:$PATH
But even afer this, the JDK 1.7 is being append to teh Path variable.
Any pointers on how i can move to JDK 1.8
I got it working. There was a script file inside /etc/profiles.d/. It was named as jdk.sh. There the JAVA_HOME and PATH was being set. I changed this to the jdk1.8 and the issue was solved. Thanks. i got a comment from Stackoverflow about the way to set the Path using script inside profile.d folder. So searched there and found the script. Took me 2 hours to figure this out... – Shabin Hashim
I'm trying to run IntelliJ on Ubuntu 14.04. I've read this question but the solutions don't apply -- I've definitely got the JDK installed rather than the JRE. When I try to run idea.sh, I get the error message:
'tools.jar' seems to be not in IDEA classpath. Please ensure JAVA_HOME
points to JDK rather than JRE.
JAVA_HOME is set to /etc/java-7-openjdk. Eclipse (in the form of Eclim) has no problem finding it. javac -version prints javac 1.7.0_55.
However, if I run sudo ./idea.sh, IntellJ launches fine. What am I missing?
I had the exact same problem half an hour ago. Took me exactly that half hour to fix it, this is how it worked for me:
Short version:
add
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
to your .bashrc, source it and you are fine.
Explanation:
After installing the JDK in Ubuntu there are multiple folders on your disk.
The root folder is
/usr/lib/jvm/java-7-openjdk-amd64/
under which the aforementioned /jre -Folder resides.
The whole problem is, that the jre/lib -Folder does not contain the tools.jar - File searched by the IDE.
Only the /usr/lib/jvm/java-7-openjdk-amd64/lib - Folder does.
To get everything working you have to specify /usr/lib/jvm/java-7-openjdk-amd64 as JAVA_HOME.
Setting /usr as your JAVA_HOME wont solve the problem as that is symlinked to /etc/alternatives which is symlinked to our old friend the /jre-Folder.
I hope this helped you!
In the 64 bit Debian 7, I solved the problem by adding this two lines of code in idea.sh under the /path/to/intellij-folder/bin/
export IDEA_JDK=/path/to/jdk/
export JAVA_HOME=/path/to/jre
And I hope it will solve the problem in Ubuntu.
It turns out JAVA_HOME was set wrong, I needed to set it to:
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
to get it working. I'm not sure why this hadn't caused me any problems before.
EDIT: This setting makes Maven angry (although Maven via IntelliJ works fine). For future readers, I believe the correct setting is:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre/
you can change your current java version as follows
alternatives --config java
alternatives --config javac
but before them you need to install your newly installed JDK in alternatives properly:
alternatives --install /usr/bin/java java [new-jdk-path]/bin/java 120 --slave /usr/bin/rmiregistry rmiregistery [new-jdk-path]/bin/rmiregistry --slave /usr/bin/keytool keytool [new-jdk-path]/bin/keytool --slave /usr/lib/tools.jar tools.jar [new-jdk-path]/lib/tools.jar
alternatives --install /usr/bin/javac javac [new-jdk-path]/bin/javac 120 --slave /usr/bin/jar jar [new-jdk-path]/bin/jar --slave /usr/bin/rmic rmic [new-jdk-path]/bin/rmic
I'm trying to install Jetty on Ubuntu 11.04 and I'm about to pull my hair out. I'm running into a classpath issue. I start Jetty with start.jar, setting JAVA_HOME to point to the JDK.
/usr/share/jetty$ export JAVA_HOME=/usr/lib/jvm/java-6-sun
/usr/share/jetty$ java -jar start.jar
[...]
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-6-sun-1.6.0.26/jre"
at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:127)
...
Notice that it's ignoring the JAVA_HOME I set, and using the jre. I've also tried this:
java -classpath /usr/lib/jvm/java-6-sun/lib/tools.jar -jar start.jar
Same error message. It's not finding, com.sun.tools.javac.Main, and that's in tools.jar.
Down in the guts of Jetty, when it's trying to compile my .jsp's, it's using Ant, and that's doing some kind of classloader tricks, I'm guessing. Does anyone know what the secret is to telling this cranky software where my tools.jar file can be found??
Note that I've gotten the same error with the sun jdk and openjdk and, yes, I do have the JDK installed, not just the JRE.
The way apt-get installs java, the java binary that's part of the JDK points into the JRE. Like this:
ls -alph /usr/lib/jvm/java-6-sun/bin/java
lrwxrwxrwx 1 root root 15 2011-10-25 18:48 /usr/lib/jvm/java-6-sun/bin/java -> ../jre/bin/java
I'm guessing that Jetty, Jasper or Ant does some trickery to try and find tools.jar based on the location of the java executable, and that's what's failing here.
Any clues are greatly appreciated. Thanks!
Though you're exporting a new JAVA_HOME environment variable, I don't see that you're also exporting a new PATH environment variable. You're probably still picking up the java executable from the original Java home location. Try including export PATH=$JAVA_HOME/bin:$PATH.
Since comments are kinda unreadable on SO, here's the info you asked for:
$ lsb_release -s -c
natty
I installed the sun JDK like so, but remember that the same error occurred with openjdk.
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get -y install sun-java6-jdk
sudo update-alternatives --config java
I'm pretty sure configuring the environment that I run start.jar in is on the wrong track, since I tried pretty hard with that and got nowhere.
Jetty call's Jasper, which calls the Ant task that compiles your JSPs. In the source for Ant's org/apache/tools/ant/taskdefs/Javac.java you can see where it's setting the classpath.
My problem likely has something to do with passing or not passing environment variables or maybe java systems properties down that chain.
An Ugly Solution
Just for laughs, I created a symbolic link from /usr/lib/jvm/java-6-sun/lib/tools.jar to /usr/lib/jvm/java-6-sun/jre/lib/ext. Ugly, huh? But, it works.
You can add tools.jar to the boot classpath of the JVM:
java -Xbootclasspath/p:/usr/lib/jvm/java-6-sun/lib/tools.jar -jar start.jar