Linked Questions
149 questions linked to/from Reading a resource file from within jar
2 votes
3 answers
10k views
How to access Maven resources in JAR file? [duplicate]
I have a Java application that I build with Maven. I have a resources folder com/pkg/resources/... that I need to access files from. For example directory.txt. I've been looking at various tutorials ...
1 vote
2 answers
12k views
Access properties file in an executable jar [duplicate]
My goal is to create an executable jar from Eclipse. I have an Eclipse project which runs fine with the structure below. My Eclipse project src/main/java -com.main ->MyClass src/main/...
2 votes
1 answer
3k views
Write an image from project resources to the byte array [duplicate]
In the project resource files, I have a default image default_image.png. I need to go to him and translate it into an array of bytes. Image image = new Image("/icons/default_image.png"); URL ...
0 votes
2 answers
4k views
How to getResourceAsStream of a file of a jar [duplicate]
How can I get a file of a jar (inside a maven dependency) with getResourceAsStream method? I tried following which returned null: InputStream is = App.class.getResourceAsStream("jquery.js");
2 votes
1 answer
3k views
Maven Properties file not found [duplicate]
I am using maven web application. The following is my project structure where I have placed my properties file. The following is my code which I am using to read this file: public static Properties ...
1 vote
1 answer
3k views
Add font.jar generated by JaspersoftStudio on maven Java project [duplicate]
Working with Jaspersoft Studio I notice that it allows you to generate a JAR file with all your fonts and XML files with each font variation definition. Its great for portability reasons, but Im not ...
0 votes
2 answers
3k views
Where do I have to put a json file to be available in Java? [duplicate]
I have a project where I like to read data from json files. However, the files cannot be found. I have already tried the java directory, as well as src/main/resources. For reading the files I use: ...
3 votes
1 answer
2k views
How to access resource files from jar file [duplicate]
I've read a bunch of similar posts, but i can't find a solution for my problem: i need to validate and parse xml files. (validation against xsd schema). The problem is that on my approach, when i run: ...
0 votes
1 answer
3k views
How to read a file from resource folder as FileInputStream in JAR Springboot [duplicate]
I am trying to read values from a json file which I have placed in my resource folder directly. I am able to run it successfully without any error in bootrun & also build successfully within ...
0 votes
2 answers
1k views
.jar file FileNotFoundException when use getClass().getResource() [duplicate]
My code use getClass().getResource() to get the file location but when I create the jar file it can't find my file even I copy the to jar file directory. And the log give me a weird path Server2018....
0 votes
1 answer
1k views
Jar can not access to resources folder [duplicate]
In my project I access the folder that is in /src/main/ressources/Mylib in eclipse it works well without any problem, but when i export the project into .jar file it does not work. The line of code ...
-2 votes
1 answer
1k views
MediaException: MEDIA_UNAVAILABLE when running project from exported JAR file [duplicate]
This is not a duplicate, because Media objects cannot be initialized with getResourceAsStream(). From the docs: "only HTTP, FILE, and JAR URIs are supported." My JavaFX project works perfectly when ...
0 votes
1 answer
752 views
Reading resource file Netbeans [duplicate]
I am trying to access High_Scores.txt file stored in folder Resources. My project tree looks like this: I am using the code shown below to access the file. Checked this similar question but the ...
0 votes
3 answers
237 views
How to read a file in a jar? [duplicate]
I am currently working on a project where I need to read an image but it doesn't work currently. As long as I run it in IntelliJ everything is fine, but as soon as I export the project into a jar I ...
0 votes
1 answer
234 views
How to get a file that it is inside my jar file? [duplicate]
I need to access to a xsd file that it's inside my jar. My problem is that my classpath is C:\Users\fabio\Documents. My jar file it's in that path too , so how can I get the file that I need? I tried ...