Tag: jmod

在Java 9+中使用JRE运行时,我可以提供运行时编译器访问吗?

我正在将应用程序迁移到Java 10.我们的应用程序通常使用JRE运行,但我们允许用户通过捆绑tools.jar并使用reflection按需加载JavacTool实例来编译自己的自定义代码。 我们的方法如下: public static JavaCompiler getJavaCompiler() { String toolJarName = “tools.jar”; File file = getResourceForClass(“tools.jar”); try { file = file.getCanonicalFile(); } catch (IOException ignore) { } if (!file.exists()) throw new RuntimeException(“Can’t find java tools file: ‘”+file+”‘”); try { URL[] urls = new URL[]{ file.toURI().toURL() }; URLClassLoader cl = URLClassLoader.newInstance(urls); return Class.forName(“com.sun.tools.javac.api.JavacTool”, false, cl).asSubclass(JavaCompiler.class).newInstance(); } […]

如何解压缩文件jre-9 / lib / modules?

在JRE-9/lib目录中(至少在Windows上),有一个名为modules的新文件,其大小约为107 MB。 是否可以提取该文件或列出其中的java模块? 我可以看到jdk-9/bin/jmod.exe有一个名为jmod的新工具,但是它用于读取位于jdk-9/jmods .jmod文件,它无法读取文件modules 。