多 JDK 导致 jmeter 无法保存的解决办法
今天在使用 jmeter 的时候发现怎么也保存不了也保存不了新的项目,我就很奇怪啊。之前一直好好的为啥突然不行了。我的日志查看面板里面一个大大的报错引起了我的注意
// 软件日志返回的
2022-02-23 16:38:11,718 ERROR o.a.j.JMeter: Uncaught exception in thread Thread[AWT-EventQueue-0,6,main]
java.lang.IllegalAccessError: class com.github.weisj.darklaf.ui.filechooser.DarkFilePaneUIBridge$DetailsTableModel (in unnamed module @0xfdefd3f) cannot access class sun.awt.shell.ShellFolder (in module java.desktop) because module java.desktop does not export sun.awt.shell to unnamed module @0xfdefd3f
at com.github.weisj.darklaf.ui.filechooser.DarkFilePaneUIBridge$DetailsTableModel.updateColumnInfo(DarkFilePaneUIBridge.java:1128) ~[darklaf-core-2.5.4.jar:2.5.4]
at com.github.weisj.darklaf.ui.filechooser.DarkFilePaneUIBridge$DetailsTableModel.<init>(DarkFilePaneUIBridge.java:1115) ~[darklaf-core-2.5.4.jar:2.5.4]
at com.github.weisj.darklaf.ui.filechooser.DarkFilePaneUIBridge.getDetailsTableModel(DarkFilePaneUIBridge.java:576) ~[darklaf-core-2.5.4.jar:2.5.4]
at com.github.weisj.darklaf.ui.filechooser.DarkFilePaneUIBridge$SortableListModel.<init>(DarkFilePaneUIBridge.java:1079) ~[darklaf-core-2.5.4.jar:2.5.4]
at com.github.weisj.darklaf.ui.filechooser.DarkFilePane.createList(DarkFilePane.java:137) ~[darklaf-core-2.5.4.jar:2.5.4]
at com.github.weisj.darklaf.ui.filechooser.DarkFileChooserUIBridge.createList(DarkFileChooserUIBridge.java:585) ~[darklaf-core-2.5.4.jar:2.5.4]
at com.github.weisj.darklaf.ui.filechooser.DarkFileChooserUIBridge$MetalFileChooserUIAccessor.createList(DarkFileChooserUIBridge.java:750) ~[darklaf-core-2.5.4.jar:2.5.4]
at com.github.weisj.darklaf.ui.filechooser.DarkFilePaneUIBridge.setViewType(DarkFilePaneUIBridge.java:376) ~[darklaf-core-2.5.4.jar:2.5.4]
at com.github.weisj.darklaf.ui.filechooser.DarkFilePaneUIBridge.propertyChange(DarkFilePaneUIBridge.java:890) ~[darklaf-core-2.5.4.jar:2.5.4]
at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:343) ~[?:?]
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:335) ~[?:?]
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:268) ~[?:?]
at java.awt.Component.firePropertyChange(Component.java:8722) ~[?:?]
at javax.swing.JComponent.setUI(JComponent.java:733) ~[?:?]
at javax.swing.JFileChooser.updateUI(JFileChooser.java:1839) ~[?:?]
at javax.swing.JFileChooser.setup(JFileChooser.java:396) ~[?:?]
at javax.swing.JFileChooser.<init>(JFileChooser.java:362) ~[?:?]
at javax.swing.JFileChooser.<init>(JFileChooser.java:309) ~[?:?]
at org.apache.jmeter.gui.util.FileDialoger.<clinit>(FileDialoger.java:42) ~[ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.gui.action.Load.doActionAfterCheck(Load.java:75) ~[ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.gui.action.AbstractActionWithNoRunningTest.doAction(AbstractActionWithNoRunningTest.java:44) ~[ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.gui.action.ActionRouter.performAction(ActionRouter.java:87) ~[ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.gui.action.ActionRouter.lambda$actionPerformed$0(ActionRouter.java:69) ~[ApacheJMeter_core.jar:5.4.3]
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318) ~[?:?]
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771) ~[?:?]
at java.awt.EventQueue$4.run(EventQueue.java:722) ~[?:?]
at java.awt.EventQueue$4.run(EventQueue.java:716) ~[?:?]
at java.security.AccessController.doPrivileged(AccessController.java:399) ~[?:?]
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) ~[?:?]
at java.awt.EventQueue.dispatchEvent(EventQueue.java:741) ~[?:?]
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) [?:?]
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) [?:?]
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) [?:?]
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) [?:?]
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [?:?]
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) [?:?]
// 控制台返回的
Uncaught Exception java.lang.IllegalAccessError:
class com.github.weisj.darklaf.ui.filechooser.DarkFilePaneUIBridge$DetailsTableModel
(in unnamed module @0xfdefd3f) cannot access class sun.awt.shell.ShellFolder
(in module java.desktop) because module java.desktop does not export sun.awt.shell
to unnamed module @0xfdefd3f in thread Thread[AWT-EventQueue-0,6,main].
See log file for details.
跟这篇文章说的挺像,虽然不是一个软件报的错误 https://bugs.eclipse.org/bugs/show_bug.cgi?id=482318 。总体来说就是因为这软件调用了内部类随时可能因为 jdk 等级而不能用。我现在的等级是 jdk17 所以需要降级,但电脑的 JAVA_HOME 不能动只能着手修改 jmeter 的启动脚本,在 jmeter.bat 中添加以下内容
rem Minimal version to run JMeter
set MINIMAL_VERSION=1.8.0
rem 在此行下面添加以下内容
rem 填写 JDK 11 或者 8 的路径,例如 C:\Program Files (x86)\Java\jdk-11.0.10
set JAVA_HOME= C:\Program Files (x86)\Java\jdk-11.0.10
set PATH=%JAVA_HOME%\bin;%PATH%
双击运行,这时候再点保存按钮就成功的展示选择界面了。
资料来源:
欢迎前往我的个人博客 www.runbrick.com,博客园同步更新。