could someone suggest elegant way to upgrade javac in Debian to version 8 ?!
javac -version
javac 1.7.0_261
java -version
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
to those who needs elegant solution:
download JVM from oracle: http://java.sun.com/products/archive/
if you use Linux as I do, *.tar.gz file can be chosen (it has all related binaries)
in Debian or other Linux untar it with command "tar xvzf PACKAGENAME.tar.gz", as a result all folders and subfolders will be created in related new folder, e.g. jdk-8u251-linux-x64. Related version of javac is in "dk-8u251-linux-x64/bin/" subfolder
copy this all structure e.g. "jdk-8u251-linux-x64" e.g. to /home/user1
modify PATH variable to allow system find related new javac: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/user1/jdk1.8.0_251/bin/
old javac can be renamed as a backup: mv /usr/bin/javac /usr/bin/javac_old
verification of the result:
javac -version
javac 1.8.0_251
Now javac on my system has the same version as java (as mentioned above, before they were quite different). In version 8 Java have several changes, e.g. some new ways how Time is handeling, which forced me to such changes.
Related
actually i im learning Linux (CentOs 7). I installed Java on root (usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java).
Now i have one question. if i type "java-version" i get
[mibe#localhost ~]$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
I thought that java only works if i set the JAVA_HOME PATH in /etc/profile. Why do i get a result for this call?
Because you installed java in /usr/lib, this folder is in system environment. When you type java -version, the system can find the command java.
But if you install java in other folder not in system environment, you must set the JAVA_HOME PATH in /etc/profile to tell the system how to find the java command, and there are other important reasons why to set the JAVA_HOME not just for this.
https://stackoverflow.com/a/27996647/11559693
I see that Java 6u65-apple is one of the available Java versions. Where does this JDK get installed on macOS? Will this JDK coexist with the newer (newest) Oracle Java JRE and JDK?
I tried what you intend using sdkman on macOS High Sierra. It should install it below ~/.sdkman but it seems not to work. This is what I and some others get, see for example https://gitter.im/sdkman/user-issues?at=5a1db5de71ad3f87363f4754
$ sdk install java 6u65-apple
tr: Illegal byte sequence
Apple requires that you agree with the Apple Software License Agreement
prior to installation.
The license agreement can be found in PDF format here:
http://images.apple.com/legal/sla/docs/JavaForOSX.pdf
Do you agree to the terms of this agreement? (Y/n): Y
Downloading: java 6u65-apple
In progress...
######################################################################## 100.0%
Binary validation passed...
We will be needing super powers...
Repackaging Java 6u65...
Attaching to the DMG...
Mounting DMG as Volume...
Volume(s) mounted successfully
Installing PKG inside DMG...
installer: Cannot install on volume / because it is disabled.
installer: Es ist bereits eine neuere Version dieses Pakets installiert.
Copy JDK Home to temp folder...
cp: /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home: No such file or directory
unlink: /Users/gg/.sdkman/tmp/out/java-6u65-apple/bundle: No such file or directory
ln: /Users/gg/.sdkman/tmp/out/java-6u65-apple/bundle: No such file or directory
Preparing archive...
zip error: Nothing to do! (try: zip -qr --symlinks /Users/gg/.sdkman/tmp/.zip . -i .)
Unmounting volume...
"/Volumes/Java for OS X 2015-001" unmounted successfully.
Done repackaging...
mv: rename /Users/gg/.sdkman/tmp/.zip to /Users/gg/.sdkman/archives/java-6u65-apple.zip: No such file or directory
unzip: cannot find or open /Users/gg/.sdkman/archives/java-6u65-apple.zip, /Users/gg/.sdkman/archives/java-6u65-apple.zip.zip or /Users/gg/.sdkman/archives/java-6u65-apple.zip.ZIP.
rm: /Users/gg/.sdkman/archives/java-6u65-apple.zip: No such file or directory
Stop! The archive was corrupt and has been removed! Please try installing again.
So I found on http://osxdaily.com/2017/06/29/how-install-java-macos-high-sierra/ a link to https://support.apple.com/kb/dl1572?locale=en_US and just clicked "Download" and it does install JDK6 inside /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/ as expected. And you can switch as you like:
$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
$ export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)
$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)
And since javac 1.6 worked fine and this was the only reason for looking into sdkman I removed it entirely.
Getting below error in Scala REPL
scala> :javap -p Add
java.lang.IllegalArgumentException: requirement failed
at scala.Predef$.require(Predef.scala:264)
at scala.tools.nsc.interpreter.JavapClass$JavapTool$.apply(JavapClass.scala:337)
at scala.tools.nsc.interpreter.JavapClass.tool$lzycompute(JavapClass.scala:37)
at scala.tools.nsc.interpreter.JavapClass.tool(JavapClass.scala:37)
at scala.tools.nsc.interpreter.JavapClass.apply(JavapClass.scala:49)
at scala.tools.nsc.interpreter.ILoop.javapCommand(ILoop.scala:332)
at scala.tools.nsc.interpreter.ILoop.$anonfun$standardCommands$6(ILoop.scala:187)
at scala.tools.nsc.interpreter.LoopCommands$LineCmd.apply(LoopCommands.scala:132)
at scala.tools.nsc.interpreter.LoopCommands.colonCommand(LoopCommands.scala:103)
at scala.tools.nsc.interpreter.LoopCommands.colonCommand$(LoopCommands.scala:101)
at scala.tools.nsc.interpreter.ILoop.colonCommand(ILoop.scala:44)
at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:696)
at scala.tools.nsc.interpreter.ILoop.processLine(ILoop.scala:416)
at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:437)
at scala.tools.nsc.interpreter.ILoop.$anonfun$process$1(ILoop.scala:1012)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:909)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:75)
at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:88)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:99)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:104)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
That entry seems to have slain the compiler. Shall I replay
your session? I can re-run each line except the last one.
[y/n]
Abandoning crashed session.
Please share if anyone encountered this issue & able to resolve. Below is the versions information. Thanks in advance!
C:\Users\email>scala -version
Scala code runner version 2.12.2 -- Copyright 2002-2017, LAMP/EPFL and Lightbend, Inc.
C:\Users\email>java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
As the answer said Why does installing Scala require additionally installing JDK?
Maybe you just installed Jre not JDK.
To solve the problem, install the corresponding version JDK.
:javap command within Scala REPL invoke the javap tool installed by JAVA SDK via java.util.spi.ToolProvider[ver2.13.1]. Jre don't include those JDK tools such as javap, jdb, jar.
On Ubuntu 16.04, I installed scala:
$ls ~/Binary/scala-2.11.8
bin doc lib man
$grep -A 2 SCALA ~/.bashrc
SCALA=~/Binary/scala-2.11.8
SBT=~/Binary/sbt
export PATH=$PATH:$SCALA/bin:$SBT/bin
With openjdk8 installed, scala fails when opening the REPL:
$javac -version
javac 1.8.0_91
$
$scala
Welcome to Scala 2.11.8 (OpenJDK 64-Bit Server VM, Java 9-internal).
Type in expressions for evaluation. Or try :help.
scala>
Failed to initialize compiler: object java.lang.Object in compiler mirror not found.
** Note that as of 2.8 scala does not assume use of the java classpath.
** For the old behavior pass -usejavacp to scala, or if using a Settings
** object programmatically, settings.usejavacp.value = true.
Failed to initialize compiler: object java.lang.Object in compiler mirror not found.
** Note that as of 2.8 scala does not assume use of the java classpath.
** For the old behavior pass -usejavacp to scala, or if using a Settings
** object programmatically, settings.usejavacp.value = true.
How can I resolve it?
Using the Java 8 version of OpenJDK resolved this issue for me.
sudo update-alternatives --config java
sudo update-alternatives --config javac
Java 8 is deprecated, so downgrading to is must NOT be an acceptable solution.
The correct solution is to upgrade your SBT to 0.13.17 or higher.
This issue appears to be with Java 9 and gets solved with Java 8.
If you have Java 8 and Java 9, and you would like to keep both, you can set your environment variable JAVA_HOME to the Java 8 path.
For example:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
You will need to replace jdk1.8.0_161.jdk with whichever version of the JDK that you have.
You can find that version with:
ls /Library/Java/JavaVirtualMachines/
Once you set that environment variable, you can open a new terminal and run java -version to see if the version was set correctly.
EDIT:
It may be worth noting that I have a Mac even though this is a linux question.
Installing java version "1.8.0_144" resolved the issue for me. I had installed jdk 1.9 previously.
If you're using an older version of Scala that is not compatible with JDK greater than 8, update to a newer version that's compatible with JDK 11. JDK 11 is current the LTS.
Versions by minor version:
For 2.11.x this means 2.11.12 or later
For 2.12.x this means 2.12.10 or later
For 2.13.x this means 2.13.1 or later
As other answers mentioned, make sure you're also using a build tool that's compatible with JDK >8 (e.g. sbt greater than 0.13.17).
Installing Java 8 resolved this issue.
I downloaded java 8 and i extracted that to the following location : /usr/lib/jvm/jdk1.8.0_172
After doing this update the JAVA_HOME path to the same : /usr/lib/jvm/jdk1.8.0_172
This will resolve the issue.
Worked with this java version "1.8.0_144"
Uninstall java and apache-spark
install java, install apache-spark
I ran into the same issue. Uninstall Java 9
sudo rm -fr /Library/Java/JavaVirtualMachines/jdk-9.jdk/
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
Ref: https://gist.github.com/schnell18/bcb9833f725be22f6acd01f94b486392
Install Java 8.
Everything seems to good now.
Btw: this was for mac. Might be useful for you.
i had a zip of my jdk at the same location. Removing the zip did the trick for me.
I have downloaded eclipse classic x86_64 3.7 cocoa on my Mac Intel Core 2 Duo with snow leopard 10.6.8
I have extracted and copied the eclipse directory to Applications folder. When run,
I get following errors
System property http.nonProxyHosts has been set to local|*.local|169.254/16|*.169.254/16 by an external source. This value will be overwritten using the values from the preferences
Unexpected error loading extension: org.eclipse.equinox.p2.metadata.repository.simpleRepository
java.lang.NoClassDefFoundError: Could not initialize class org.apache.commons.httpclient.HttpClient at org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientBrowseFileTransferFactory$1.sendBrowseRequest(HttpClientBrowseFileTransferFactory.java:53)
Error while reading from repository: http://download.eclipse.org/releases/indigo/site.xml.
I have following java version
java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-384-10M3425)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-384, mixed mode)
I have tried with eclipse classic 32 and 64 bit versions, with both i have the same problem .
I have also tried tweaking around priority of java version (32 or 64) under Java preferences.
Deleting /Library/Java/Extensions/log4j-1.2.15.jar resolved the issue.
Incase you are using ubuntu instead and had this problem, just go
cd /usr/java/packages/lib/ext/
sudo rm log4j-1.2.15.jar
sudo rm slf4j-*
I also had this problem and had nothing under /Library/Java/Extensions
You can notice that Eclipse reports: "The value will be overwritten using values from the preferences". So what you can do - visit Preferences > Network Connections and under 'Proxy Bypass' add Host: *
This has resolved the issue for me.
I set this to solve the problem:
http.sslVerify false in the egit config file.