简体   繁体   English

无法在Ubuntu 14.04上运行Swing程序

[英]Cannot run Swing programs on ubuntu 14.04

I have to do a GUI project for a class, and I cannot run the program I'm writing. 我必须为一个类做一个GUI项目,但是我无法运行正在编写的程序。 I have looked everywhere so I tried to run the simplest program: 我到处都看过,所以我尝试运行最简单的程序:

package start; 
/*
* HelloWorldSwing.java requires no other files. 
*/
  import javax.swing.*;        

  public class HelloWorldSwing {
  /**
  * Create the GUI and show it.  For thread safety,
  * this method should be invoked from the
  * event-dispatching thread.
  */
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("HelloWorldSwing");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Add the ubiquitous "Hello World" label.
    JLabel label = new JLabel("Hello World");
    frame.getContentPane().add(label);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
    }

public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });
    }
}

I have the java compiler, I know because when I use java -version on my terminal it returns this: 我有Java编译器,因为我在终端上使用java -version时会返回以下内容:

openjdk version "9-internal"
OpenJDK Runtime Environment (build 9-internal+0-2016-04-14-195526.buildd.src)
OpenJDK Client VM (build 9-internal+0-2016-04-14-195526.buildd.src, mixed mode)

I also have the JRE. 我也有JRE。

When I compile it, I use javac start/HelloWorldSwing.java (It does compile) But when i try to run it with java start.HelloWorldSwing it returns this: 当我编译它时,我使用javac start/HelloWorldSwing.java (它确实可以编译),但是当我尝试使用java start.HelloWorldSwing运行它时,它返回以下内容:

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0xb6aafe48, pid=4166, tid=4180
#
# JRE version: OpenJDK Runtime Environment (9.0) (build 9-internal+0-2016-04-14-195526.buildd.src)
# Java VM: OpenJDK Client VM (9-internal+0-2016-04-14-195526.buildd.src, mixed mode, serial gc, linux-x86)
# Problematic frame:
# C  [libjava.so+0x18e48]  JNU_GetEnv+0x18
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %P" (or dumping to /home/carcamo/Escritorio/myhw/core.4166)
#
# An error report file with more information is saved as:
# /home/carcamo/Escritorio/myhw/hs_err_pid4166.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

I would really appreciate any help I can get on this issue 我真的很感激我能在这个问题上获得任何帮助

Have you tried using a version of Java that is a supported release? 您是否尝试过使用受支持的Java版本? Try openjdk 8, or download the Oracle Java 8 release (currently 8u102). 尝试使用openjdk 8,或下载Oracle Java 8发行版(当前为8u102)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM