import java.io.File; import javax.swing.*; public class TestResouce extends JFrame { public TestResouce() { setSize(500,500); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String filename = TestResouce.class.getResource("TestResouce.class").getFile(); JTextArea out = new JTextArea(); out.append(filename+"\n"); add(new JScrollPane(out)); File file = new File(filename); if (file.exists()) out.append("file is exists"+"\n"); setVisible(true); file.getAbsolutePath(); } public static void main(String[] args) { new TestResouce(); } }