gpt4 book ai didi

java - 应用程序在 Eclipse 中使用 --add-modules=java.se.ee 运行,但不在命令行上运行

转载 作者:行者123 更新时间:2023-12-02 12:56:32 25 4
gpt4 key购买 nike

我正在使用 Java 9-ea 来运行 app在 Eclipse 中构建并在命令行上运行同一应用程序的 Ant 构建的 jar。在 Eclipse 中,如果我传递 --permit-illegal-access --add-modules=java.se.ee VM args,则一切正常,但如果我在命令行上传递相同的参数:

java --add-modules=java.se.ee --permit-illegal-access -jar swing/build/jar/OpenRocket.jar

运行时失败:

java.lang.RuntimeException: Error starting OpenRocket
at net.sf.openrocket.startup.jij.JarInJarStarter.runMain(JarInJarStarter.java:40)
at net.sf.openrocket.startup.OpenRocket.main(OpenRocket.java:36)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:563)
at net.sf.openrocket.startup.jij.JarInJarStarter.runMain(JarInJarStarter.java:38)
... 1 more
Caused by: java.lang.reflect.InvocationTargetException
at java.desktop/java.awt.EventQueue.invokeAndWait(EventQueue.java:1323)
at java.desktop/java.awt.EventQueue.invokeAndWait(EventQueue.java:1298)
at java.desktop/javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1475)
at net.sf.openrocket.startup.SwingStartup.main(SwingStartup.java:76)
... 6 more
Caused by: com.google.common.util.concurrent.ExecutionError: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2212)
at com.google.common.cache.LocalCache.get(LocalCache.java:4053)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4057)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4986)
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4992)
at com.google.inject.internal.FailableCache.get(FailableCache.java:48)
at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:50)
at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:138)
at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:550)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:887)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:808)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:285)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:217)
at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:893)
at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:46)
at com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:50)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:134)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
at com.google.inject.Guice.createInjector(Guice.java:99)
at com.google.inject.Guice.createInjector(Guice.java:73)
at com.google.inject.Guice.createInjector(Guice.java:62)
at net.sf.openrocket.startup.SwingStartup.runInEDT(SwingStartup.java:143)
at net.sf.openrocket.startup.SwingStartup.access$000(SwingStartup.java:43)
at net.sf.openrocket.startup.SwingStartup$1.run(SwingStartup.java:79)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:303)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:759)
at java.desktop/java.awt.EventQueue.access$500(EventQueue.java:97)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:712)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:706)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:88)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:729)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:199)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2212)
at com.google.common.cache.LocalCache.get(LocalCache.java:4053)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4057)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4986)
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4992)
at com.google.inject.internal.FailableCache.get(FailableCache.java:48)
at com.google.inject.internal.MembersInjectorStore.get(MembersInjectorStore.java:68)
at com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:75)
at com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:29)
at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:37)
at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:33)
at com.google.inject.internal.FailableCache$1.load(FailableCache.java:37)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3628)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2336)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2295)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2208)
... 37 more
Caused by: java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3134)
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2285)
at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:688)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:380)
at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies(ConstructorBindingImpl.java:165)
at com.google.inject.internal.InjectorImpl.getInternalDependencies(InjectorImpl.java:616)
at com.google.inject.internal.InjectorImpl.cleanup(InjectorImpl.java:572)
at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:558)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:887)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:808)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:285)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:217)
at com.google.inject.internal.SingleFieldInjector.<init>(SingleFieldInjector.java:42)
at com.google.inject.internal.MembersInjectorStore.getInjectors(MembersInjectorStore.java:131)
at com.google.inject.internal.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:98)
at com.google.inject.internal.MembersInjectorStore.access$000(MembersInjectorStore.java:37)
at com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:45)
at com.google.inject.internal.MembersInjectorStore$1.create(MembersInjectorStore.java:42)
at com.google.inject.internal.FailableCache$1.load(FailableCache.java:37)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3628)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2336)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2295)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2208)
... 52 more
Caused by: java.lang.ClassNotFoundException: javax.script.ScriptEngineFactory
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:553)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:486)
... 76 more

失败归结为

java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory

但是 --add-modules=java.se.ee 应该公开该类,以便可以找到它(这似乎在 Eclipse 中有效)。

可能出了什么问题?

最佳答案

这个问题似乎是我的应用程序特有的。我注意到它在启动时做了一些阴暗的事情:https://github.com/openrocket/openrocket/blob/master/swing/src/net/sf/openrocket/startup/jij/JarInJarStarter.java

关于java - 应用程序在 Eclipse 中使用 --add-modules=java.se.ee 运行,但不在命令行上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44401858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com