我已经通过终端在我的OS X上安装了groovy
,我无法运行任何东西。发生以下异常:
java.lang.SecurityException: Prohibited package name: java.lang
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:659)
at java.lang.ClassLoader.defineClass(ClassLoader.java:758)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at org.codehaus.groovy.tools.RootLoader.oldFindClass(RootLoader.java:175)
at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:147)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:100)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)
它的开发人员似乎使用了java.lang
包名,这使得类加载器生气。
如果可以帮助我检查tools.jar
在以下行中找到的startGroovy
:
208 # For Darwin, use classes.jar for TOOLS_JAR
209 TOOLS_JAR="$JAVA_HOME/lib/tools.jar"
在我的情况下JAVA_HOME
是:
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/
更多详情:
$ which java
/usr/bin/java
$ which groovy
/Users/maksim/.sdkman/candidates/groovy/current/bin/groovy
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/
echo $CLASSPATH
为空。
$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)