Jar File Missing File Path

Disavowed

Everything works fine while my ide is open, but when i build my project it's not working as jar file. I guess the problem is at the path of my resource, I can't find any way to handle this problem, please help me if you have any solution.

public void playSound(String filename){

        String strFilename = filename;

        try {
            ClassLoader classLoader = getClass().getClassLoader();
            soundFile = new File(classLoader.getResource(strFilename).getFile());
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
Brett Okken

You cannot address a resource in your jar as a File. In your IDE it likely is a file in the file system, not a resource in a jar. You need to be able to read the content as a URL and/or InputStream.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to get the path of a running JAR file?

From Dev

Add properties file to build path of runnable jar

From Dev

Java: How to show Jar file path for "method undefined" exceptions?

From Dev

Missing tools.jar file

From Dev

Java File System: UNC path is missing sharename

From Dev

How to get file path from inside .jar source code

From Dev

Android project jar file missing after pushing to github

From Dev

Error opening zip file or JAR manifest missing : C:\Program

From Dev

How to place PostgreSQL driver jar file on class path in eclipse?

From Dev

Get a file in a jar in jar

From Dev

How to construct a Path from a jar:file URL?

From Dev

How to get the file path location of a .jar dependency?

From Dev

Error opening zip file or JAR manifest missing : jrebel.jar

From Dev

Gradle- Importing a JAR file with absolute windows path?

From Dev

Specifying generic file path to work with a jar-file

From Dev

Copying a file with robocopy (long name and path, and many spaces) - Missing argument

From Dev

Adding jar file to instrumentation path

From Dev

Python module "trace": file path missing

From Dev

Copying a file with robocopy (long name and path, and many spaces) - Missing argument

From Dev

Fallback on Local js file If file is missing from remote path

From Dev

Jar cannot find the path to the file inside

From Dev

Missing tools.jar file

From Dev

Missing parameter in configuration file. Keyword: path

From Dev

Android project jar file missing after pushing to github

From Dev

JFrame design change after generating JAR file? Image missing

From Dev

Java get path of executing jar without .jar file

From Dev

How to get a running Jar's file path?

From Dev

Adding jar file to instrumentation path

From Dev

Get relative path from jar file

Related Related

  1. 1

    How to get the path of a running JAR file?

  2. 2

    Add properties file to build path of runnable jar

  3. 3

    Java: How to show Jar file path for "method undefined" exceptions?

  4. 4

    Missing tools.jar file

  5. 5

    Java File System: UNC path is missing sharename

  6. 6

    How to get file path from inside .jar source code

  7. 7

    Android project jar file missing after pushing to github

  8. 8

    Error opening zip file or JAR manifest missing : C:\Program

  9. 9

    How to place PostgreSQL driver jar file on class path in eclipse?

  10. 10

    Get a file in a jar in jar

  11. 11

    How to construct a Path from a jar:file URL?

  12. 12

    How to get the file path location of a .jar dependency?

  13. 13

    Error opening zip file or JAR manifest missing : jrebel.jar

  14. 14

    Gradle- Importing a JAR file with absolute windows path?

  15. 15

    Specifying generic file path to work with a jar-file

  16. 16

    Copying a file with robocopy (long name and path, and many spaces) - Missing argument

  17. 17

    Adding jar file to instrumentation path

  18. 18

    Python module "trace": file path missing

  19. 19

    Copying a file with robocopy (long name and path, and many spaces) - Missing argument

  20. 20

    Fallback on Local js file If file is missing from remote path

  21. 21

    Jar cannot find the path to the file inside

  22. 22

    Missing tools.jar file

  23. 23

    Missing parameter in configuration file. Keyword: path

  24. 24

    Android project jar file missing after pushing to github

  25. 25

    JFrame design change after generating JAR file? Image missing

  26. 26

    Java get path of executing jar without .jar file

  27. 27

    How to get a running Jar's file path?

  28. 28

    Adding jar file to instrumentation path

  29. 29

    Get relative path from jar file

HotTag

Archive