【问题标题】:Java Error "Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: mslinks/ShellLink"Java 错误“线程“AWT-EventQueue-0”中的异常 java.lang.NoClassDefFoundError:mslinks/ShellLink”
【发布时间】:2021-02-11 22:22:40
【问题描述】:

我正在尝试使用 ShellLink(位于 https://github.com/DmitriiShamrikov/mslinks/releases)为我在编码中移动的一些 .exe 文件创建快捷方式

public static void createShortcut(String folder, String system) throws IOException
{
    //Folder is where the .exe is. Linking directly to the .exe not the folder it's in
    //system is the desktop of the user's computer. I've tried both linking it to the folder and a .lnk file. 
    ShellLink.createLink(folder, system); 
    //ShellLink mslinks.ShellLink.createLink(String target, String linkpath)
}

错误

线程“AWT-EventQueue-0”中的异常 java.lang.NoClassDefFoundError: mslinks/ShellLink

错误指向

createShortcut(Shortcut+"\\UniversalDesktop.exe", "C:\\Users\\" + Username + "\\Desktop\\" + selectedSystem + ".lnk");

也许有更好的方法通过 Java 编程创建快捷方式?请注意,ShellLink 的 .JAR 在我的 JRE 系统库中使用 import mslinks.ShellLink;。我不知道导致错误出现的原因

【问题讨论】:

  • 仅仅因为您导入它并不意味着它在您运行程序时被加载。应该有一种方法可以将 jar 添加到您的类路径中。您使用的是哪个 IDE?
  • 日食。使用 Java 的最新版本

标签: java shortcut


【解决方案1】:

我在 Modulepath 而不是 Classpath 中有 JRE。这导致了错误

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多