Runnable jar works fine with java -jar, but double click problems

I use the eclipse IDE and I just exported my project using the 'export-> Runnable Jar'. In my code, I downloaded a map using

URL map1url = this.getClass().getResource("map01.txt");

and later

inputmap = new File(map1url.getFile());

and then looked at my data with

Scanner sc = null;
    try {
        sc = new Scanner(inputmap);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

, map01.txt , , map01.txt. java -jar, , . map01.txt , jar, , , , . java -jar, . ? ? map01.txt - , . , jar, . ,

URL url = this.getClass().getResource("myImage.gif");
    try {
        BufferedImage myImage = ImageIO.read(url);
    } catch (IOException e) {
    }    

, ? , , ?

0
1

" (map1url.getFile())", java.io.File, . ( , "java -jar", , .

getResource(). openStream() ?

+2

All Articles