1

I need help. I am writing a Java FX application in Eclipse, with the use of e(fx)clipse. I am using it's generic build.fxbuild to generate the ant script needed to develop my .EXE file.

The application works perfectly in Eclipse IDE. And when packaged with a 64-bit JDK, it even works perfectly after being deployed as an .EXE.

My problem arises when I package it with a 32-bit JDK for a 32-bit install. With the 32-bit JDK, it still runs perfectly in Eclipse. When I create the .EXE, it seemingly runs fine. The problem is... the software is made to take an excel file of addresses, compare them to a sql database of addresses, and then append the excel file with recommendations of "ID"'s from the SQL database to give customer service a reference of which address (from excel) may exist in our database. The only thing the software doesn't do is the appending. But, it creates the XSSFWorkbook, and resaves the workbook and opens it. So it's getting the beginning code of this segment, as well as the end. But something is happening in the middle for 32-bit vs 64-bit.

Need help!

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();
    }

}
  • Needs more debug, maybe cowbell. Rinse and repeat until you know what the something in the middle is. – zapl Nov 27 '15 at 19:58
  • Likely duplicate: [Same Apache poi (excel) code acting differently depending on system types (32bit, 64bit)](http://stackoverflow.com/questions/33790512/same-apache-poi-excel-code-acting-differently-depending-on-system-types-32bit/33837943) – Gagravarr Nov 27 '15 at 23:24
  • how can you deploy it as an exe? – cssGEEK Nov 28 '15 at 11:50

1 Answers1

2

I got a similar problem with SWT

The general problem is when you need some native functions (like screen system), which depend on a particular jar.

related discussions about FX:

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)?

My way:

1 find the JAR

Finding javafx jar file for windows

2 embark the 2 jars in you app

3 at runtime, check 32/64

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

4 load the "good" jar at runtime (check before is already loaded)

How should I load Jars dynamically at runtime?

Community
  • 1
  • 1