JVM 在 Ubuntu 上尝试打开 JavaFX 保存对话框或打开对话框时崩溃

2024-04-14

在 Windows 中一切正常,我只是使用 JavaFX 和 Java 1.8.0_131 从操作系统中选择文件。

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fa5f45cde90, pid=4843, tid=0x00007fa59b31c700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_131-b11) (build 1.8.0_131-b11)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.131-b11 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libpthread.so.0+0x9e90]  pthread_mutex_lock+0x0
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/alexander/Desktop/Roots/hs_err_pid4843.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.
#
Aborted (core dumped)

您可以使用的代码:

import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.Stage;

public final class FileChooserSample extends Application {

    private Desktop desktop = Desktop.getDesktop();

    @Override
    public void start(final Stage stage) {
        stage.setTitle("File Chooser Sample");

        final FileChooser fileChooser = new FileChooser();

        final Button openButton = new Button("Open a Picture...");
        final Button openMultipleButton = new Button("Open Pictures...");

        openButton.setOnAction(
            new EventHandler<ActionEvent>() {
                @Override
                public void handle(final ActionEvent e) {
                    configureFileChooser(fileChooser);
                    File file = fileChooser.showOpenDialog(stage);
                    if (file != null) {
                        openFile(file);
                    }
                }
            });

        openMultipleButton.setOnAction(
            new EventHandler<ActionEvent>() {
                @Override
                public void handle(final ActionEvent e) {
                    configureFileChooser(fileChooser);
                    List<File> list = 
                        fileChooser.showOpenMultipleDialog(stage);
                    if (list != null) {
                        for (File file : list) {
                            openFile(file);
                        }
                    }
                }
            });

        final GridPane inputGridPane = new GridPane();

        GridPane.setConstraints(openButton, 0, 0);
        GridPane.setConstraints(openMultipleButton, 1, 0);
        inputGridPane.setHgap(6);
        inputGridPane.setVgap(6);
        inputGridPane.getChildren().addAll(openButton, openMultipleButton);

        final Pane rootGroup = new VBox(12);
        rootGroup.getChildren().addAll(inputGridPane);
        rootGroup.setPadding(new Insets(12, 12, 12, 12));

        stage.setScene(new Scene(rootGroup));
        stage.show();
    }

    public static void main(String[] args) {
        Application.launch(args);
    }

        private static void configureFileChooser(final FileChooser fileChooser){                           
        fileChooser.setTitle("View Pictures");
        fileChooser.setInitialDirectory(
            new File(System.getProperty("user.home"))
        ); 
    }


    private void openFile(File file) {
        try {
            desktop.open(file);
        } catch (IOException ex) {
            Logger.getLogger(
                FileChooserSample.class.getName()).log(
                    Level.SEVERE, null, ex
                );
        }
    }
}

以上代码摘自Oracle教程->!Link http://docs.oracle.com/javafx/2/ui_controls/file-chooser.htm


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

JVM 在 Ubuntu 上尝试打开 JavaFX 保存对话框或打开对话框时崩溃 的相关文章

随机推荐

  • 如何将 sqlite 3.8.2 升级到 >= 3.8.3

    在使用 Python 3 7 2 的虚拟环境中 我尝试运行 djangopython manage py startap myapp我收到此错误 raise ImproperlyConfigured SQLite 3 8 3 or late
  • PHP mail() 中的空 $_POST

    对于以下方面的一些帮助将不胜感激 我已经在网络和 stackoverflow 上搜索了几个小时 我的php邮件功能有这个问题 我的网站上有一个表单 该网站使用 WordPress 其中包含两个文本字段 姓名和电话号码 表单中还有一个隐藏字段
  • 如何快速有效地调试 CloudFormation 模板?

    CloudFormation 是一项功能强大的 AWS 产品 允许以编程方式创建 AWS 资源堆栈 例如应用程序的网络层 https s3 amazonaws com cloudformation templates us east 1 v
  • Crm 2011 Outlook 客户端 - 设置有关强制

    我们的客户正在使用 Microsoft CRM 2011 Outlook 客户端 他们有独特的业务需求 他们希望所有使用 Outlook 发送电子邮件的员工都必须强制执行 设置相关内容 很奇怪吧 如果用户在发送电子邮件时忘记设置相关内容 O
  • (PostgreSQL)错误:无法打开关系

    我收到这个奇怪的错误 Caused by org postgresql util PSQLException ERROR could not open relation base 17369 1684 No such file or dir
  • 链接静态库后去除名称

    在 iOS 6 的静态库项目中 c 文件中的某些函数被其他函数引用 因此被视为全局符号 但不应向该库的用户公开 我怎么能够strip这些函数名出来了吗 另外 我怎样才能隐藏这些 obj 文件名 以便没有人可以看到 o 名称nm output
  • 清理 PHP/HTML 页面

    有人知道有什么好用的工具可以清理php和html文件吗 我以前使用过 Tidy 但它在单独处理 php 代码方面效果不佳 我知道 tidy 有多种实现 但是有没有专门针对 html 和 php 页面的工具统治冠军 清理代码从将 PHP 与
  • Golang 预处理器类似 C 风格的编译开关

    GO语言有预处理器吗 当我查找互联网时 几乎没有将 pgo 转换为 go 的方法 而且 我想知道这在 Go 中是否可行 ifdef COMPILE OPTION compile this code elif compile another
  • 将 html 表单值传递给 google 搜索查询[重复]

    这个问题在这里已经有答案了 旁注 在每个人告诉我谷歌的自定义搜索引擎之前 我一直在使用它直到现在 但我发现很难设计该搜索框的样式 并且它在我的网站上崩溃了 Hello 我正在尝试创建一个使用 HTML 表单输入的 google 搜索查询 我
  • VBA:运行时错误“91”?

    我在这里想做的就是保存对当前活动窗口的引用 但它似乎不起作用 它在最后一行给了我一个运行时错误 Dim SourceWindow As Window QACheckWindow As Window SourceWindow ActiveWi
  • iOS:处理长按并拖动以选择另一个按钮。 (如键盘)

    我很难找到有关如何处理触摸事件以支持与键盘类似的行为的正确文档 我想要的是一个按钮 当我长按它时 它会在按钮上方显示一个自定义视图控制器 但我希望用户能够将手指拖动到其他按钮之一 无需将手指离开屏幕 我长按按钮 它是自定义视图控制器的所有设
  • 上下文是只读的

    Helo大师 我必须动态创建一个JNDI数据源 我尝试使用名为SetupApplicationListener的侦听器来完成它 这是开始WEB LIB web xml
  • 将参数从 pug 传递到 JSX

    我正在使用 Express 和 React 构建游戏 我需要访问我的 userIdindex jsx文件来在我的控制器上执行操作 例如增加用户分数 我的路线呈现index pug文件同时传递user id param server js a
  • 具体时间通知

    我在特定时间收到通知 请参阅我的代码 Create alarm manager AlarmManager alarmMgr0 AlarmManager getSystemService Context ALARM SERVICE Creat
  • JavaScript 字符串换行符是什么?

    Is nJavaScript 中适用于所有平台的通用换行符序列 如果不是 我如何确定当前环境的特征 我不是在询问 HTML 换行元素 br 我问的是 JavaScript 字符串中使用的换行符序列 我刚刚使用这段愚蠢的 JavaScript
  • 如何让我的 Android 应用程序出现在超省电模式下

    一些三星设备具有超省电模式 可以关闭 wifi 将屏幕变成灰度并限制使用一些基本应用程序 但是 它确实允许您添加一些可以使用的应用程序 这些应用程序包括 Facebook 和 WhatsApp 如何让我的应用程序出现在此列表中 我必须对应用
  • ajax响应错误(XML解析错误:找不到元素位置:moz-nullprincipal)

    我无法得到 ajax 的响应 请指导我如何解决此错误 我从已签入的服务器成功返回数据小提琴网络调试器并且 ajax 仍然显示错误 XML 解析错误 找不到元素位置 moz nullprincipal 6b0a1ac2 50ab 4053 9
  • 如何在 Rails 视图中注释代码?

    当我使用 Rails 并开发视图时 我经常想注释掉代码 类和模型足够简单 但是views有点棘手 在视图中注释代码的最佳方式是什么 这样它就不会被任何东西解释 HTML 给了我们尽管这里包含的代码似乎无论如何都会被解释 或者还有更 Rail
  • Flutter FCM onBackgroundMessage 处理程序给出 null 检查错误

    我正在尝试为我的应用程序实现通知 但是在初始化通知时FirebaseMessaging onBackgroundMessage notificationHandler 给出错误 Error E flutter 28265 错误 flutte
  • JVM 在 Ubuntu 上尝试打开 JavaFX 保存对话框或打开对话框时崩溃

    在 Windows 中一切正常 我只是使用 JavaFX 和 Java 1 8 0 131 从操作系统中选择文件 A fatal error has been detected by the Java Runtime Environment