Hi I am getting a strange error when I am running my JavaFX application from a JAR. When I attempt to use a drop area in my app that I added, I get a strange error. This is what I get when run from CMD (java.lang.reflect.InvocationTargetException). On the GUI the drop operation just gets stuck and doesn't complete.
I know that the code works, because when I run it from my IDE it works fine.
Any help would be great.
public void onDragDrop(DragEvent event){
files = new ArrayList<>();
Dragboard db = event.getDragboard();
boolean success = false;
if(db.hasFiles()){
//Do something with file.
List<File> temp_files = db.getFiles();
for(File f : temp_files){
if(FilenameUtils.getExtension(f.getPath()).equals("ovpn")){
files.add(f);
}
}
lbl_dragger.setText("Files Dropped: " + files.size());
success = true;
}
event.setDropCompleted(success);
event.consume();
}
UPDATE: Upon further testing, it seems that the error is actually coming from the line below:
if(FilenameUtils.getExtension(f.getPath()).equals("ovpn")){
files.add(f);
}
There seems to be some kind of error with the library I was using (ApacheCommons). As a workaround (unless this question gets an answer) using a simple (but less accurate) method will be suitable. See below if you too are stuck on this:
if(f.getAbsolutePath().contains(".ovpn")){
files.add(f);
}