gpt4 book ai didi

java - 32 位应用程序可以在 Eclipse 中运行,但部署后不能运行。 (没有错误..)

转载 作者:行者123 更新时间:2023-11-30 03:09:19 25 4
gpt4 key购买 nike

我需要帮助。我正在 Eclipse 中使用 e(fx)clipse 编写 Java FX 应用程序。我使用它的通用 build.fxbuild 来生成开发 .EXE 文件所需的 ant 脚本。

该应用程序在 Eclipse IDE 中完美运行。当使用 64 位 JDK 打包时,它甚至在部署为 .EXE 后也可以完美运行。

当我将其与 32 位 JDK 打包进行 32 位安装时,出现了问题。使用32位的JDK,在Eclipse中依然可以完美运行。当我创建 .EXE 时,它似乎运行良好。问题是...该软件用于获取地址的 Excel 文件,将它们与地址的 SQL 数据库进行比较,然后在 Excel 文件中附加 SQL 数据库中的“ID”建议,以便为客户服务提供帮助我们的数据库中可能存在哪个地址(来自 Excel)的引用。该软件唯一不做的就是附加。但是,它创建 XSSFWorkbook,并重新保存工作簿并打开它。所以它获取了该段的开始代码以及结束代码。但 32 位与 64 位之间发生了一些事情。

需要帮助!

public static void writeMatchedRecords(XSSFWorkbook wb, HashMap<Integer, ExcelAddress> excelRecords,
HeaderTemplate template) {

if (Defaults.DEBUG) {
System.out.println("Writing " + excelRecords.size() + " excel records");
}

// Variable to allow writing to excel file
CreationHelper createHelper = wb.getCreationHelper();

// Iterate through every row of the excel sheet
for (Row row : wb.getSheetAt(0)) {

if (excelRecords.containsKey(row.getRowNum() + 1)) {

ExcelAddress excelTemp = excelRecords.get(row.getRowNum() + 1);
HashMap<Double, ArrayList<ShipTo>> matchedShipTos = excelTemp.getMatchedShipTos();

if (Defaults.DEBUG) {
System.out.print(row.getCell(template.getColName()) + " from Excel matches with " + excelTemp.getName() + " from HASH with " + matchedShipTos.size() + " matches.");
}

if (matchedShipTos.isEmpty() == false) {

if (Defaults.DEBUG) {
System.out.println(" (non-zero confirmed)");
}

// If Matched Ship contains 100% matches remove all other
// matches
if (matchedShipTos.containsKey(1d)) {
HashMap<Double, ArrayList<ShipTo>> tempHM = new HashMap<Double, ArrayList<ShipTo>>();
tempHM.put(1d, matchedShipTos.get(1d));
matchedShipTos.clear();
matchedShipTos.putAll(tempHM);
}

Map<Double, ArrayList<ShipTo>> sortedShipTos = new TreeMap<Double, ArrayList<ShipTo>>(matchedShipTos).descendingMap();

for (Map.Entry<Double, ArrayList<ShipTo>> entry : sortedShipTos.entrySet()) {

for (ShipTo shipTo : entry.getValue()) {

if (Defaults.DEBUG) {
System.out.print("Ship to Match: ");
System.out.print(shipTo.getName());
System.out.print(" P: " + entry.getKey() + "\n");
}

if (row.getLastCellNum() == wb.getSheetAt(0).getRow(0).getLastCellNum()) {
// Create additional headers
wb.getSheetAt(0).getRow(0).createCell(row.getLastCellNum())
.setCellValue(createHelper.createRichTextString("Probability"));
wb.getSheetAt(0).getRow(0).createCell(row.getLastCellNum() + 1)
.setCellValue(createHelper.createRichTextString("P21 - Ship to ID"));
wb.getSheetAt(0).getRow(0).createCell(row.getLastCellNum() + 2)
.setCellValue(createHelper.createRichTextString("P21 - Ship to Name"));
wb.getSheetAt(0).getRow(0).createCell(row.getLastCellNum() + 3).setCellValue(
createHelper.createRichTextString("P21 - Ship to Address Line 1"));
}

row.createCell(row.getLastCellNum()).setCellValue(entry.getKey());
row.createCell(row.getLastCellNum())
.setCellValue(createHelper.createRichTextString(Integer.toString(shipTo.getId())));
row.createCell(row.getLastCellNum())
.setCellValue(createHelper.createRichTextString(shipTo.getName()));
row.createCell(row.getLastCellNum())
.setCellValue(createHelper.createRichTextString(shipTo.getAddress1()));

}

}

}
}
}

Date date = new Date();
int rand = (int) (Math.random() * 10);
File file = new File(System.getProperty("user.home") + "/Desktop/"
+ String.format("%1$s %2$tF%3$s", template.getTemplateName(), date, " (" + rand + ").xlsx"));

try

{
FileOutputStream fileout = new FileOutputStream(file);
wb.write(fileout);
fileout.close();
Desktop.getDesktop().open(file);
} catch (

Exception e)

{
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Could not save data");
alert.setContentText("Could not save data to file:\n" + file.getPath());

alert.showAndWait();
}

}

最佳答案

我在 SWT 中遇到了类似的问题

一般的问题是当你需要一些依赖于特定 jar 的 native 功能(如屏幕系统)时。

有关外汇的相关讨论:

Creating 32 bit JavaFx Native Bundle in 64 bit machine

https://github.com/javafx-maven-plugin/javafx-maven-plugin/issues/81

Does JavaFX work in 32-bit Windows? (or with a 32-bit JVM)?

我的方式:

1 找到 JAR

Finding javafx jar file for windows

2 在您的应用程序中启动 2 个 jar

3运行时,检查32/64

Properties prop=java.lang.System.getProperties();
String 32_64=prop.getProperty("sun.arch.data.model");
// => 32 or 64

4 在运行时加载“好”jar(检查之前是否已加载)

How should I load Jars dynamically at runtime?

关于java - 32 位应用程序可以在 Eclipse 中运行,但部署后不能运行。 (没有错误..),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33963891/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com