I have reviewed other answers to questions about this problem and tried what they suggested, but with no success. In my program, I have these five lines all in succession:
String curDir = System.getProperty("user.dir"); System.out.println(curDir); File f = new File("/home/brian/workspace/Color Sampler/src/Data.txt"); if(f.exists() && !f.isDirectory()) { System.out.println("success"); } Scanner input = new Scanner(new File("/home/brian/workspace/Color Sampler/src/Data.txt")); The first four lines result in the output:
/home/brian/workspace/Color Sampler success The file, to my knowledge, is located in MULTIPLE locations:
/home/brian/workspace/Color Sampler /home/brian/workspace/Color Sampler/src /home/brian/workspace/Color Sampler/bin Despite all this, I'm still getting the exception. I've tried it with all three of the above filepaths. The file also is not open anywhere so it should be readable. I'm ripping my hair out at this point as I've spent over an hour on a simple filename specification.
Here's the exception:
Exception in thread "AWT-EventQueue-1" java.lang.Error: Unresolved compilation problem: Unhandled exception type FileNotFoundException at WindowDestroyer.windowOpened(WindowDestroyer.java:46) at java.awt.Window.processWindowEvent(Window.java:1972) at javax.swing.JFrame.processWindowEvent(JFrame.java:290) at java.awt.Window.processEvent(Window.java:1933) at java.awt.Component.dispatchEventImpl(Component.java:4649) at java.awt.Container.dispatchEventImpl(Container.java:2103) at java.awt.Window.dispatchEventImpl(Window.java:2588) at java.awt.Component.dispatchEvent(Component.java:4475) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:675) at java.awt.EventQueue.access$300(EventQueue.java:96) at java.awt.EventQueue$2.run(EventQueue.java:634) at java.awt.EventQueue$2.run(EventQueue.java:632) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:108) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:119) at java.awt.EventQueue$3.run(EventQueue.java:648) at java.awt.EventQueue$3.run(EventQueue.java:646) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:108) at java.awt.EventQueue.dispatchEvent(EventQueue.java:645) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177) at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)