Got a strange problem here. I have a pdf file, Readme.pdf that I stuck in the source folder and pull it as a resource. I know the file does in fact exist in the .jar file as I have looked at the file with an archiver and it is physical inside the .jar. The code works fine on a windows machine and launches the appropriate Adobe viewer. On my Linux machine I get the following error:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: The file: file:/home/jeff/TenDataManager/TenDataManager.jar!/com/n7yg/datamanager/Readme.pdf doesn't exist.
at java.awt.Desktop.checkFileValidation(Desktop.java: 209)
at java.awt.Desktop.open(Desktop.java:270)
at com.n7yg.datamanager.MainForm$12.mouseReleased(Mai nForm.java:395)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEven tMulticaster.java:290)
What is interesting is that it will run and find the file when it is run inside of the Eclipse IDE.
public static final URL readme = MainForm.class.getResource("/com/n7yg/datamanager/Readme.pdf"); mntmReadme.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (Desktop.isDesktopSupported()) { try { File myFile = new File(readme.getFile()); Desktop.getDesktop().open(myFile); } catch (IOException ex) { // no application registered for PDFs } } } });
Any ideas why this might be happening?