在Ubuntu 18.04上使用Eclipse 2018-09进行编译时,有关策略加密机制的错误。
我在互联网上找到了一些解决方案,但没有一个起作用。
我决定删除JVM目录和Eclipse,然后重新安装JDK 11和Eclipse。我没有JDK的问题,由于相同的错误,我的Eclipse安装程序也有问题,它仅直接与Eclipse软件包一起运行,但是编译时却具有加密机制。
我的代码:
package fr.wildcodeschool.idetest;
import java.io.IOException;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;
public class Start {
public static void main(String [] args) throws IOException {
System.out.println(ProcessHandle.current().pid());
JFrame jf = new JFrame("Gotcha!");
jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
jf.add(new JLabel(new ImageIcon(new URL("https://i.imgur.com/ZGv8Usc.png"))));
jf.pack();
jf.setVisible(true);
}
}
编译错误:
Exception in thread "Image Fetcher 0" java.lang.ExceptionInInitializerError
at java.base/javax.crypto.KeyGenerator.nextSpi(KeyGenerator.java:363)
at java.base/javax.crypto.KeyGenerator.<init>(KeyGenerator.java:176)
at java.base/javax.crypto.KeyGenerator.getInstance(KeyGenerator.java:244)
at java.base/sun.security.ssl.JsseJce.getKeyGenerator(JsseJce.java:228)
at java.base/sun.security.ssl.SSLConfiguration.<clinit>(SSLConfiguration.java:109)
at java.base/sun.security.ssl.ProtocolVersion.<clinit>(ProtocolVersion.java:42)
at java.base/sun.security.ssl.SSLContextImpl$AbstractTLSContext.<clinit>(SSLContextImpl.java:559)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at java.base/java.security.Provider$Service.getImplClass(Provider.java:1848)
at java.base/java.security.Provider$Service.newInstance(Provider.java:1824)
at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
at java.base/javax.net.ssl.SSLContext.getInstance(SSLContext.java:168)
at java.base/javax.net.ssl.SSLContext.getDefault(SSLContext.java:99)
at java.base/javax.net.ssl.SSLSocketFactory.getDefault(SSLSocketFactory.java:123)
at java.base/javax.net.ssl.HttpsURLConnection.getDefaultSSLSocketFactory(HttpsURLConnection.java:335)
at java.base/javax.net.ssl.HttpsURLConnection.<init>(HttpsURLConnection.java:292)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.<init>(HttpsURLConnectionImpl.java:95)
at java.base/sun.net.www.protocol.https.Handler.openConnection(Handler.java:62)
at java.base/sun.net.www.protocol.https.Handler.openConnection(Handler.java:57)
at java.base/java.net.URL.openConnection(URL.java:1051)
at java.desktop/sun.awt.image.URLImageSource.getConnection(URLImageSource.java:101)
at java.desktop/sun.awt.image.URLImageSource.getDecoder(URLImageSource.java:111)
at java.desktop/sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:263)
at java.desktop/sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:212)
at java.desktop/sun.awt.image.ImageFetcher.run(ImageFetcher.java:176)
Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism
at java.base/javax.crypto.JceSecurity.<clinit>(JceSecurity.java:120)
... 27 more
Caused by: java.lang.SecurityException: Couldn't parse jurisdiction policy files in: unlimited
at java.base/javax.crypto.JceSecurity.setupJurisdictionPolicies(JceSecurity.java:357)
at java.base/javax.crypto.JceSecurity$1.run(JceSecurity.java:111)
at java.base/javax.crypto.JceSecurity$1.run(JceSecurity.java:108)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/javax.crypto.JceSecurity.<clinit>(JceSecurity.java:107)
... 27 more
可以帮我吗?