0

I have a Java project that uses Microsoft Access to store/retrieve data, and it works fine in both netbeans and the jar file. However, when I use launch4j to open/save data, nothing happens. I'm not sure if there's a way to get error messages from an exe, but if there is tell me how and I'll try to get it. Here is the code I use to open an Access file:

JFileChooser jfc = new JFileChooser();
        jfc.setCurrentDirectory(new File("/home/me/Documents"));
    int returnValue = jfc.showOpenDialog(null);
    if (returnValue == JFileChooser.APPROVE_OPTION) {
        File selectedFile = jfc.getSelectedFile();
        String route = (selectedFile.getAbsolutePath());
                     try {
       Statement statement;
    ResultSet resultSet;
     Connection connection=DriverManager.getConnection("jdbc:ucanaccess://"+route);
     statement = connection.createStatement();
table.getColumns().clear();
 resultSet = statement.executeQuery("SELECT * FROM Database");
  values=0;
      for ( int i = 0; i<table.getItems().size(); i++) {
          a[i]=0;
          b[i]=0;
table.getItems().clear();
}
      int j=0;
      table.getColumns().addAll(rowCol,aCol, bCol);
          while(resultSet.next()) {
               values = resultSet.getInt(1);
               a[j] =  resultSet.getDouble(2);
               b[j] = resultSet.getDouble(3);
                data.add(new info(a[j],b[j++],values));

    }
       //   System.out.println(values);
            }
            catch (Exception ex ){
       ex.printStackTrace();
   }

    }

Any help that could be offered would be greatly appreciated, thanks

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
Evan
  • 193
  • 9
  • can you run this .exe file from the cmd terminal, maybe you'll see some feedback. – Kh.Taheri Jun 29 '17 at 14:32
  • I just did so but it doesn't give me any error message – Evan Jun 29 '17 at 14:36
  • 1
    is this windows like path "/home/me/Documents"! – Kh.Taheri Jun 29 '17 at 14:50
  • Yes it's windows – Evan Jun 29 '17 at 14:56
  • Possibly related question [here](https://stackoverflow.com/q/19917960/2144390). – Gord Thompson Jun 29 '17 at 14:56
  • I think what @Kh.Taheri is hinting at is that "/home/me/Documents" is not a valid path under Windows. – Gord Thompson Jun 29 '17 at 14:57
  • When I use the exe file it automatically goes to the document section when I try to opena file so I don't think that's the problem but maybe I'm wrong. What would be a correct path? – Evan Jun 29 '17 at 14:59
  • the path should be something like this "C:/Users//...." – Kh.Taheri Jun 29 '17 at 15:00
  • However, you have to check the link which provided by @Evan , you might need to add all jar libraries to your exe. – Kh.Taheri Jun 29 '17 at 15:02
  • I actually already did the solution that Gord linked. Originally the exe file didn't run at all, and while doing that made it run, I still can't open/save anything. I tried changing the path location, and while it didn't change anything, I accidentally ran it in launch4j this time which gave me the following error message: `Exception in thread"JavaFX Application Thread" java.lang.NoSuchMethodError: org.hsqldb.DatabaseURL.parseURL(Ljava/lang/String;ZZ)Lorg/hsqldb/persist/HsqlProperties;` – Evan Jun 29 '17 at 15:09

1 Answers1

0

Solved the issue- apparently I had two versions of hsqldb in my library. Deleting the extra fixed the issue. Thanks everyone

Evan
  • 193
  • 9