Made this little program to teste some GUI and Tess4j.
public static void main(String[] args) {
JButton open = new JButton();
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new java.io.File("C:"));
fc.setDialogTitle("Classificador de Documentos");
if (fc.showOpenDialog(open) == JFileChooser.APPROVE_OPTION){
}
JFrame wait = new JFrame("Resultado");
wait.setVisible(true);
wait.setSize(300, 300);
JLabel labelwait = new JLabel("Loading");
JPanel panelwait = new JPanel();
wait.add(panelwait);
panelwait.add(labelwait);
File imageFile = new File(fc.getSelectedFile().getAbsolutePath());
ITesseract instance = new Tesseract();
instance.setLanguage("por");// JNA Interface Mapping
// ITesseract instance = new Tesseract1(); // JNA Direct Mapping
try {
String result = instance.doOCR(imageFile);
if (result.toLowerCase().contains("ecocardiograma")){
JFrame frame = new JFrame("Resultado");
frame.setVisible(true);
frame.setSize(300, 300);
JLabel label = new JLabel("Este ficheiro é um ecocardiograma");
JPanel panel = new JPanel();
frame.add(panel);
panel.add(label);
}
else {
JFrame frame = new JFrame("Resultado");
frame.setVisible(true);
frame.setSize(300, 300);
JLabel label = new JLabel("Este ficheiro não é um ecocardiograma");
JPanel panel = new JPanel();
frame.add(panel);
panel.add(label);
}
} catch (TesseractException e) {
JFrame frame = new JFrame("Resultado");
frame.setVisible(true);
frame.setSize(300, 300);
JLabel label = new JLabel(e.getMessage());
JPanel panel = new JPanel();
frame.add(panel);
panel.add(label);
}
}
When running this code on Eclipse IDE it works as intended, but when running on a .jar file it gets stuck on the second frame labeled "Loading"
What can be the issue?