NoSuchFileException when running jar file

Scriptim

When I run a jar file that accesses other files in the src directory, I get the following RuntimeException:

Exception in thread "main" java.nio.file.NoSuchFileException: src\FileToBeAccessed.txt.lck at sun.nio.fs.WindowsException.translateToIOException(Unknown Source) at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source) at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source) at sun.nio.fs.WindowsFileSystemProvider.newFileChannel(Unknown Source) at java.nio.channels.FileChannel.open(Unknown Source) at java.nio.channels.FileChannel.open(Unknown Source) at java.util.logging.FileHandler.openFiles(Unknown Source) at java.util.logging.FileHandler.(Unknown Source) at Program.main(Program.java:30)

The code works fine when I run it directly without building a jar file.

Pumphouse

You'll need to change how you access resources in a jar to a stream.

this.getClass().getResourceAsStream("/file.txt");

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Strange NoSuchFileException when trying to read a file

From Java

NoSuchFileException when creating a file using nio

From Dev

Jar file not working (filenotfoundexception when running in cmd)

From Dev

Error creating bean when running .JAR file

From Java

NoClassDefFoundError when running Scala jar file

From Dev

Issue with main when running jar file

From Dev

.jar not running when passed valid file in args

From Dev

JavaFX runtime exceptions when running .jar file

From Dev

Unable to Access Jar File When Running Akka

From Dev

Database not updating when running from .jar file

From Dev

Java properties file in jar not found when running jar

From Java

java.nio.file.NoSuchFileException When File.transferTo() is called

From Java

Running JAR file on Windows

From Dev

Java jar file not running

From Dev

ConcurrentExecution Exception & nio.file.NoSuchFileException when creating Symbolic Link

From Java

NoSuchFileException when using java.nio.file.Files.createTempDirectory

From Java

Couldn't find or load main class when running jar file

From Java

How to set the -Xmx when start running a jar file?

From Dev

How do I easily elevate when running a .jar file?

From Dev

Restrict kill commands when running jar file using a shell script

From Dev

How to access file in a JAR when running a Maven build

From Java

Ant buildfile not able to put jar file in classpath when running other jar file

From Dev

NoSuchFileException while reading a file

From Dev

NoSuchFileException even if file exists

From Dev

Running a jar file that has an image

From Java

Running a compiled Jar file in Jenkins

From Dev

.JAR Executable file not running properly

From Java

include external jar when running java -jar

From Java

Apache poi java: Image not showing in document when running JAR file in another computer

Related Related

  1. 1

    Strange NoSuchFileException when trying to read a file

  2. 2

    NoSuchFileException when creating a file using nio

  3. 3

    Jar file not working (filenotfoundexception when running in cmd)

  4. 4

    Error creating bean when running .JAR file

  5. 5

    NoClassDefFoundError when running Scala jar file

  6. 6

    Issue with main when running jar file

  7. 7

    .jar not running when passed valid file in args

  8. 8

    JavaFX runtime exceptions when running .jar file

  9. 9

    Unable to Access Jar File When Running Akka

  10. 10

    Database not updating when running from .jar file

  11. 11

    Java properties file in jar not found when running jar

  12. 12

    java.nio.file.NoSuchFileException When File.transferTo() is called

  13. 13

    Running JAR file on Windows

  14. 14

    Java jar file not running

  15. 15

    ConcurrentExecution Exception & nio.file.NoSuchFileException when creating Symbolic Link

  16. 16

    NoSuchFileException when using java.nio.file.Files.createTempDirectory

  17. 17

    Couldn't find or load main class when running jar file

  18. 18

    How to set the -Xmx when start running a jar file?

  19. 19

    How do I easily elevate when running a .jar file?

  20. 20

    Restrict kill commands when running jar file using a shell script

  21. 21

    How to access file in a JAR when running a Maven build

  22. 22

    Ant buildfile not able to put jar file in classpath when running other jar file

  23. 23

    NoSuchFileException while reading a file

  24. 24

    NoSuchFileException even if file exists

  25. 25

    Running a jar file that has an image

  26. 26

    Running a compiled Jar file in Jenkins

  27. 27

    .JAR Executable file not running properly

  28. 28

    include external jar when running java -jar

  29. 29

    Apache poi java: Image not showing in document when running JAR file in another computer

HotTag

Archive