I am new to Linux and new to Java.
Previously i had jdk1.8.0_171 installed, along with netbeans 8.2.
During one of the Kali updates, JDK 8 was completely replaced by JDK 10.
As a result of that, netbeans stopped functioning.
I attempted to install JDK 8, and it seemed to work.
java -version
was showing both 8 and 10 after using
sudo update-alternatives --config java
to select different versions.
That however had no effect on netbean, it was completely unusable.
Then i made a decision to completely remove everything that had to do with Java, and install a fresh copy of JDK 8.
sudo apt-get purge openjdk*
and
sudo apt-get purge icedtea*
was used.
java -version and sudo dpkg --list|grep -i jdk
was used to make sure nothing was left.
Additionally running
apt-get update
removed some unused leftovers.
Next i downloaded and executed jdk 8_171 tar.gz file. It ran, but gave some error in the end.
Next i tried to remove Netbeans, but received a message saying that i would need JDK to be installed to do anything about Netbeans.
java -version
showed nothing. Purging of both openjdk and icedtea did nothing, both say that files are not present.
Then i have tried to install JDK + Netbean combo, and that resulted in error message saying that JDK is already installed.
So now i am in the situation where i cant remove Netbean, Netbean is not working because JDK is not present. JDK cant be installed because apparently i already have JDK. Where JDK was installed i cant figure out, searching manually and with using
whereis name
is not yielding any meaningful results.
Detailed explanation on what is going on and what should i do about it would be greatly appreciated.
Related
I'm having trouble removing Java 9 from my macOS Sierra system.
I accidentally installed Java 9, instead of Java 8, so now all my Eclipse projects give me these warnings: Build path specifies execution environment JavaSE-1.8. There are no JREs installed in the workspace that are strictly compatible with this environment.
I have used the following guide, but it did not work. Here is my command output when running java -version from the command line:
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
for macOS high sierra removing java 9:
delete the java folder you find in the dir shown to you after executing:
/usr/libexec/java_home -V
use "Go to" in finder and copy and paste the dir to get there
There are two commands which are very simple and useful. If you want to keep multiple versions simply set JAVA_HOME to version you want to use.
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_(version you want to use).jdk/Contents/Home
Example--> export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
Else in addition to above command remove/uninstall additional jdk version from your system with below command.
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-(version you want to remove).jdk/
Example --> sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/
Please refer below github link for additional details -->
https://gist.github.com/schnell18/bcb9833f725be22f6acd01f94b486392
Thanks
On MacOS you can list what JDKs you have installed and where they are installed to with:
/usr/libexec/java_home -V
If you want to select one of the installed JDKs to be used as default, you can do:
/usr/libexec/java_home -v 1.8
Verify which is now default with java -version.
You can manually add the location of other installed JREs in Eclipse via Preferences / Java / Installed JREs , press Add, and then point it to one of the locations should with the -V option above. You can then check it to select which is default for your projects.
After viewing which Java Virtual Machines I had on my computer using the following command:
ls /Library/Java/JavaVirtualMachines
I realized no additional JDK's would appear after using the Java 8 installer (besides Java 9). When doing further research, it turns out I had installed the other version that is not a SE development kit and it was just working in web browsers, not for the terminal.
For anyone having the same issue, make sure you use the Java SE Development Kit 8.
Uninstall Oracle Java using the Terminal:
Note: To uninstall Java, you must have Administrator privileges and execute the remove command either as root or by using the sudo tool.
Remove one directory and one file (a symlink), as follows:
Click on the Finder icon located in your dock
Click on the Utilities folder
Double-click on the Terminal icon
In the Terminal window Copy and Paste the commands below:
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -fr ~/Library/Application\ Support/Java
Do not attempt to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS.
Source:https://www.java.com/en/
I believe the problem is navigating to the correct directory... Once you are where you are supposed to be you can run the sudo commands to remove whichever versions of java you want to remove.
First, run the command in the terminal to determine which version of Java you are running,
java -version
then you can navigate to pesky version of java that you intend to delete by using the following command:
cd /Library/Java/JavaVirtualMachines
then once you see are in the JavaVirtualMachines path, type in ls to see what versions of Java you have installed,
ls
and finally when you know which version or versions of Java you want to uninstall:
sudo rm -rf jdk-10.0.1.jdk #or whichever version you want to delete
I know that you've asked about how to uninstall the java version. But, I think it's important how to manage your Java version in a very good way.
For me, the best way is using SDKMan, a very nice tool for managing you Development tools like Java.
Here you can learn more about it: http://sdkman.io/
You can install your Java version as follow:
$ sdk install java
You can install others tools like Scala:
$ sdk install scala 2.12.1
Uninstall your tools very easy:
$ sdk uninstall java 9
And so on. Hope this helps you in future installation of your development tools.
I am having an issue trying to upgrade to Java 8 from Java 6 on my Mac running Mac OS X 10.10.5, with Java 8 seemingly not getting recognized.
I installed Java 8 via the .dmg installer: jre-8u66-macosx-x64.dmg, yet when I enter: java -version, it reports:
java version "1.6.0_65".
Yet, I noticed under the Java Panel via System Preference, the Java Runtime Environment Settings Panel is displaying 1.8.0_102.
From poking around I have noticed:
1) Java 8 seems to have installed into: /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk
2) Java 6 seems to have been installed into:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk
I then noticed a post on StackOverflow recommending to use "brew" to install Java, and not use the official installer for Mac, as it is broken. When I went to install brew I got this error message:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
I got this error message: Illegal variable name.
And then I read that "brew" is broken on versions of El Capitan and above.
So, what do I need to do to get this upgrade to Java 8 to work???
Appreciate any help with this! Thanks!
your java command points to the stub binary which uses current version configured
$ ls -la /usr/bin/java
lrwxr-xr-x 1 root wheel 74 Feb 5 2015 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
all you need is to update your JAVA_HOME(I've added that to my ~/.profile):
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
There's a topic which describes this in-depth Need help understanding Oracle's Java on Mac
set your JAVE_HOME to java 8.
For the brew thing, guess you might have run it in csh/tcsh..change it to bash and the script will working to install brew.
I don't know about the brew thing. Looks like you have two jdks and the one with /System/Library/Java/JavaVirtualMachines/1.6.0.jdk has the $PATH set for it but the new one you installed doesn't have its $PATH set for it yet. I would recommend following,
i. either delete the old one and then set the $PATH for new one
ii. just set the $PATH for new one but try to keep both JDK in same location
in both cases you want to have $JAVA_HOME yield the path for your latest jdk which should work.
here is link that might be helpful
https://cloudlink.soasta.com/t5/CloudTest-Knowledge-Base/Adding-JDK-Path-in-Mac-OS-X-Linux-or-Windows/ta-p/43867
for setting the $PATH for you. In plain terms, you have to find a file in your mac that is called .bash_profile and then in that file you have to set the $PATH for your new jdk or which ever jdk you want to work with. This should take little research if you don't know but its not very difficult. Hope this helps..
When I originally installed Android Studio, I had it with JDK 1.7. Now JDK 8 is required to build for Android N, so I installed it. I tried redirecting the project structure to the JDK 1.8 install, but every time I push OK, it automatically goes back to JDK 1.7. Am I missing something here on updating JDK?
You need to set the default JDK, if you just installed the 1.8
(most cases) you now have the 1.7 and the 1.8 installed.
if you want make sure what java you are using as default run the command.
javac -version
and
java -version
if is a old version you can set using the command (for Debian base Linux).
sudo apt-get install oracle-java8-set-default
PS: sorry if you are using Windows I'm not able to help you,
and next time will nice to know which OS are you using .
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 seen this question asked so many times, but there was no precise answer to my problem. My story is simple - I downloaded a legitimate JAR file, for a functioning and advertised application, from here: https://github.com/kamilfb/mqtt-spy/wiki/Downloads.
The application brings the obvious instruction to start it as java -jar mqtt-spy-0.2.0-jar-with-dependencies.jar but that results in the well known error, being in my case Error: Could not find or load main class pl.baczkowicz.mqttspy.Main
My system is Ubuntu 15.04, Java version is
openjdk version "1.8.0_45-internal"
OpenJDK Runtime Environment (build 1.8.0_45-internal-b14)
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)
I don't have another computer to test it elsewhere. I did some checks and the JAR file looks pretty much normal. I even tried de-compressing it and running the class directly, it won't budge, same error message. I tried some online .class analysis tools, nothing caught my attention. Also I reviewed about a dozen of pages referring to "Could not find or load" problem. No luck so far.
Not sure if anyone bothers, but I did my Java Programmers certification with Sun yet in 2005... and I feel frustrated now. While I hope there is an easy solution for my problem, e.g. some nice Ubuntu issue ;-), I am ready to dig deeper, and looking for any hints that would guide me to finding the root cause of this issue.
Additionally install Java FX, since this is required and worked for me (Ubuntu 16: package openfx):
apt install openjfx
See also this issue:
https://github.com/kamilfb/mqtt-spy/issues/88
I currently successfully run it on openjdk version "1.8.0_121" here.
Thank you it was very helpful for me. I had exactly the same problem, and looking the solution here as well
My fix was:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
then, install the JDK Oracle 8
sudo apt-get install oracle-java8-installer
and then, checking java:
sudo update-alternatives --config java
It is displayed between other choices:
0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1082
auto mode
......
Press to keep the current choice[*], or type selection number:
I keep the 0 current choice [*]
then, running mqttspy worked just fine :-)
java -jar mqtt-spy-0.5.1-jar-with-dependencies.jar
The solution that worked in my case was to use HotSpot Java 8, from Oracle.
Just in case you have multiple java versions, you can run the jar file by giving the java file path as well.
brew install --cask liberica-jdk#17-full
brew install --cask liberica-jdk17-full
/Library/Java/JavaVirtualMachines/liberica-jdk-17-full.jdk/Contents/Home/bin/java -jar mqtt-spy-1.0.1-beta-b18-jar-with-dependencies.jar