java.lang.UnsatisfiedLinkError

问题描述 投票:0回答:2

我正在java swing中做一个简单的项目,只是为了打发时间。 当我尝试启动应用程序时,它给了我这个错误:

   Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\Java\bin\awt.dll: Routine di inizializzazione della libreria di collegamento dinamico (DLL) non riuscita
    at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
    at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169)
    at java.base/jdk.internal.loader.NativeLibraries.findFromPaths(NativeLibraries.java:310)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:280)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2416)
    at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:809)
    at java.base/java.lang.System.loadLibrary(System.java:1893)
    at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:1380)
    at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:1378)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
    at java.desktop/java.awt.Toolkit.loadLibraries(Toolkit.java:1377)
    at java.desktop/java.awt.Toolkit.<clinit>(Toolkit.java:1410)
    at java.desktop/java.awt.Component.<clinit>(Component.java:622)
    at com.company.Main.main(Main.java:6)

这是代码(我有 3 个类):

这是班级页面:

package com.company;

import javax.swing.*;
import java.awt.*;

public class Page extends JFrame {
    Header header = new Header();
    public Page(){
        super("FW Ultra");
        this.setSize(1000, 700);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.getContentPane().setLayout(new FlowLayout());

        this.add(header);

        this.setVisible(true);
    }
}

这是类头:

package com.company;

import javax.swing.*;
import java.awt.*;

public class Header extends JPanel {
    public Header(){
        super();
        this.setLayout(new BorderLayout());
        add(new JLabel("FVU | Film Viewer Ultra"),  BorderLayout.WEST);
        add(new JLabel("Version 1.0"),  BorderLayout.EAST);
    }
}

这是主要的

package com.company;

public class Main {

    public static void main(String[] args) {
        Page p = new Page();
    }
}

请帮助我

java
2个回答
0
投票

我对您的代码做了一些更改并提出了这个 GUI。我将 GUI 的大小减小了一半,这样它会更适合答案。

我更改了您所有三个课程中的一些代码。我将你的类设置为内部类,这样我就可以将它们作为一个块发布。你应该把它们分开。

我通过调用

SwingUtilities
invokeLater
方法启动了 Swing GUI。此方法确保 Swing 组件在 Event Dispatch Thread 上创建并执行。

这是完整的可运行代码。

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class FileViewerMain {

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                new FileViewerMain().new Page();
            }
        });
    }
    
    public class Page extends JFrame {
        Header header = new Header();
        public Page(){
            super("FW Ultra");
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.add(new Header(), BorderLayout.BEFORE_FIRST_LINE);
            this.setSize(500, 350);
            this.setVisible(true);
        }
    }
    
    public class Header extends JPanel {
        public Header(){
            super();
            this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
            this.setLayout(new BorderLayout());
            add(new JLabel("FVU | Film Viewer Ultra"),  BorderLayout.WEST);
            add(new JLabel("Version 1.0"),  BorderLayout.EAST);
        }
    }

}

0
投票

Java HotSpot(TM) 64 位服务器 VM 警告:仅引导加载程序类支持共享,因为已附加引导程序类路径

运行springboot项目后出现此错误。我想知道如何解决它

© www.soinside.com 2019 - 2024. All rights reserved.