如何在Ubuntu上使用Open JDK 1.9在ubuntu上安装sbt 0.13.8或最新版本

时间:2016-12-25 01:51:13

标签: java ubuntu sbt

我在ubuntu 16.10上安装sbt时遇到问题。我安装了Open JDK 1.9。我按照这里的说明进行了Unix:

http://www.scala-sbt.org/release/docs/Manual-Installation.html

我在〜/ .bashrc文件中添加了以下内容:

JAVA_HOME="/usr/lib/jvm/java-1.9.0-openjdk-amd64" 
SBT_HOME="$HOME/sbt-launcher-packaging-0.13.13" 
PATH="$SBT_HOME/bin/sbt":$PATH

当我从命令行运行sbt时,我得到一个无法识别的命令错误。 如果我将JAR文件和sbt脚本放在/ bin /中并运行,我会收到此错误:

Getting org.scala-sbt sbt 0.13.8 ...
java.lang.ExceptionInInitializerError
    at javax.crypto.JceSecurityManager.<clinit>(java.base@9-Ubuntu/JceSecurityManager.java:65)

at javax.crypto.Cipher.getConfiguredPermission(java.base@9-Ubuntu/Cipher.java:2595)
at javax.crypto.Cipher.getMaxAllowedKeyLength(java.base@9-Ubuntu/Cipher.java:2619)
at sun.security.ssl.CipherSuite$BulkCipher.isUnlimited(java.base@9-Ubuntu/CipherSuite.java:602)
at sun.security.ssl.CipherSuite$BulkCipher.<init>(java.base@9-Ubuntu/CipherSuite.java:574)
at sun.security.ssl.CipherSuite$BulkCipher.<clinit>(java.base@9-Ubuntu/CipherSuite.java:460)
at sun.security.ssl.CipherSuite.<clinit>(java.base@9-Ubuntu/CipherSuite.java:1074)
at sun.security.ssl.SSLContextImpl.getApplicableSupportedCipherSuiteList(java.base@9-Ubuntu/SSLContextImpl.java:353)
at sun.security.ssl.SSLContextImpl.access$100(java.base@9-Ubuntu/SSLContextImpl.java:41)
at sun.security.ssl.SSLContextImpl$AbstractTLSContext.<clinit>(java.base@9-Ubuntu/SSLContextImpl.java:582)
at java.lang.Class.forName0(java.base@9-Ubuntu/Native Method)
at java.lang.Class.forName(java.base@9-Ubuntu/Class.java:291)
at java.security.Provider$Service.getImplClass(java.base@9-Ubuntu/Provider.java:1844)
at java.security.Provider$Service.newInstance(java.base@9-Ubuntu/Provider.java:1820)
at sun.security.jca.GetInstance.getInstance(java.base@9-Ubuntu/GetInstance.java:236)
at sun.security.jca.GetInstance.getInstance(java.base@9-Ubuntu/GetInstance.java:164)
at javax.net.ssl.SSLContext.getInstance(java.base@9-Ubuntu/SSLContext.java:166)
at javax.net.ssl.SSLContext.getDefault(java.base@9-Ubuntu/SSLContext.java:98)
at javax.net.ssl.SSLSocketFactory.getDefault(java.base@9-Ubuntu/SSLSocketFactory.java:123)
at javax.net.ssl.HttpsURLConnection.getDefaultSSLSocketFactory(java.base@9-Ubuntu/HttpsURLConnection.java:332)
at javax.net.ssl.HttpsURLConnection.<init>(java.base@9-Ubuntu/HttpsURLConnection.java:289)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.<init>(java.base@9-Ubuntu/HttpsURLConnectionImpl.java:85)
at sun.net.www.protocol.https.Handler.openConnection(java.base@9-Ubuntu/Handler.java:62)
at sun.net.www.protocol.https.Handler.openConnection(java.base@9-Ubuntu/Handler.java:57)
at java.net.URL.openConnection(java.base@9-Ubuntu/URL.java:1049)
at org.apache.ivy.util.url.BasicURLHandler.getURLInfo$57a0216e(BasicURLHandler.java:66)
at org.apache.ivy.util.url.BasicURLHandler.getURLInfo(BasicURLHandler.java:54)
at org.apache.ivy.plugins.repository.url.URLResource.init(URLResource.java:65)
at org.apache.ivy.plugins.repository.url.URLResource.exists(URLResource.java:81)
at org.apache.ivy.plugins.resolver.RepositoryResolver.findResourceUsingPattern(RepositoryResolver.java:97)
at org.apache.ivy.plugins.resolver.AbstractPatternsBasedResolver.findResourceUsingPatterns(AbstractPatternsBasedResolver.java:96)
at org.apache.ivy.plugins.resolver.AbstractPatternsBasedResolver.findIvyFileRef(AbstractPatternsBasedResolver.java:66)
at org.apache.ivy.plugins.resolver.BasicResolver.getDependency(BasicResolver.java:228)
at org.apache.ivy.plugins.resolver.ChainResolver.getDependency(ChainResolver.java:104)
at org.apache.ivy.core.resolve.IvyNode.loadData(IvyNode.java:169)
at org.apache.ivy.core.resolve.VisitNode.loadData(VisitNode.java:292)
at org.apache.ivy.core.resolve.ResolveEngine.fetchDependencies(ResolveEngine.java:714)
at org.apache.ivy.core.resolve.ResolveEngine.doFetchDependencies(ResolveEngine.java:799)
at org.apache.ivy.core.resolve.ResolveEngine.fetchDependencies(ResolveEngine.java:722)
at org.apache.ivy.core.resolve.ResolveEngine.getDependencies(ResolveEngine.java:594)
at org.apache.ivy.core.resolve.ResolveEngine.resolve(ResolveEngine.java:234)
at xsbt.boot.Update.xsbt$boot$Update$$lockedApply(Update.scala:106)
at xsbt.boot.Update$$anon$4.call(Update.scala:100)
at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)
at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:97)
at xsbt.boot.Using$.withResource(Using.scala:10)
at xsbt.boot.Using$.apply(Using.scala:9)
at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
at xsbt.boot.Locks$.apply0(Locks.scala:31)
at xsbt.boot.Locks$.apply(Locks.scala:28)
at xsbt.boot.Update.apply(Update.scala:101)
at xsbt.boot.Launch.update(Launch.scala:352)
at xsbt.boot.Launch.xsbt$boot$Launch$$retrieve$1(Launch.scala:208)
at xsbt.boot.Launch$$anonfun$3.apply(Launch.scala:216)
at scala.Option.getOrElse(Option.scala:120)
at xsbt.boot.Launch.xsbt$boot$Launch$$getAppProvider0(Launch.scala:216)
at xsbt.boot.Launch$$anon$2.call(Launch.scala:196)
at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)
at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:97)
at xsbt.boot.Using$.withResource(Using.scala:10)
at xsbt.boot.Using$.apply(Using.scala:9)
at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
at xsbt.boot.Locks$.apply0(Locks.scala:31)
at xsbt.boot.Locks$.apply(Locks.scala:28)
at xsbt.boot.Launch.locked(Launch.scala:238)
at xsbt.boot.Launch.app(Launch.scala:147)
at xsbt.boot.Launch.app(Launch.scala:145)
at xsbt.boot.Launch$.run(Launch.scala:102)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism
    at javax.crypto.JceSecurity.<clinit>(java.base@9-Ubuntu/JceSecurity.java:91)
    ... 78 more
    Caused by: java.lang.NullPointerException
        at sun.nio.fs.UnixPath.normalizeAndCheck(java.base@9-Ubuntu/UnixPath.java:75)
        at sun.nio.fs.UnixPath.<init>(java.base@9-Ubuntu/UnixPath.java:69)
        at sun.nio.fs.UnixFileSystem.getPath(java.base@9-Ubuntu/UnixFileSystem.java:280)
        at java.nio.file.Paths.get(java.base@9-Ubuntu/Paths.java:84)
        at javax.crypto.JceSecurity.setupJurisdictionPolicies(java.base@9-Ubuntu/JceSecurity.java:254)
        at javax.crypto.JceSecurity.access$000(java.base@9-Ubuntu/JceSecurity.java:49)
        at javax.crypto.JceSecurity$1.run(java.base@9-Ubuntu/JceSecurity.java:82)
        at javax.crypto.JceSecurity$1.run(java.base@9-Ubuntu/JceSecurity.java:79)
        at java.security.AccessController.doPrivileged(java.base@9-Ubuntu/Native Method)
        at javax.crypto.JceSecurity.<clinit>(java.base@9-Ubuntu/JceSecurity.java:78)
        ... 78 more
    Error during sbt execution: java.lang.ExceptionInInitializerError

2 个答案:

答案 0 :(得分:2)

据我所知,到目前为止,SBT已于2016年12月28日与java9不兼容,遇到同样的问题,对我来说最有效的方法是先卸载openjdk-9,如下所示

sudo apt-get autoremove openjdk-9-jre-headless

sudo apt-get remove default-jdk

sudo apt-get purge openjdk-9-jre-headless gcj-4.9-jre-headless

然后因为我已经安装了java 8

> ~$ java -version
openjdk version "1.8.0_111"
OpenJDK Runtime Environment (build 1.8.0_111-8u111-b14-2ubuntu0.16.10.2-b14)
OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)

我已按照sbt page中的程序进行操作,一切按预期工作

答案 1 :(得分:0)

我尝试在library/openjdk:9 Docker容器中运行Maven时遇到此问题。我通过在java.lang.NoClassDefFoundError: Could not initialize class javax.crypto.JceSecurityManager从Oracle获取Java 9 JDK并设置JAVA_HOME,以与Q https://jdk9.java.net/download/中的其他评论者相同的方式解决了问题。似乎这两个jar文件(在其他答案中提到)在Docker镜像中不存在。