Questions tagged [getresource]
283 questions
0
votes
1 answer
Scala getResourceAsStream() fails silently while loading keystore
I'm trying to use getResourceAsStream to load a java keystore albeit unsuccessfully. I'm not sure why it fails, but I'm loading it inside Play! 2.0 from a subfolder inside a typical folder.
Here's the folder structure and keystore location:
play…

crockpotveggies
- 12,682
- 12
- 70
- 140
-1
votes
2 answers
getClass().getResource is pre apend the workin directory
I’m developing a application where I need to load a schema file (xsd) as resource from the jar file,
but the file path of getClass().getResource(“..”) is getting prefixed with the working directory.
This is the code:
//ClassLoader classLoader =…
-1
votes
1 answer
How to give the correct path of a file in getClass().getResource()
In this fourm are a lot of questions but none is similar to mine.
I always get a NullPointerException if i try to jump two folders up in the directory. If i just jump up one folder, the program finds my .html file...
This is the java part where I…

Henning
- 39
- 8
-1
votes
1 answer
NullPointerException when Jar file executes. Nothing works
I feel like I've tried everything. These are some of the examples of the code I've tried which runs perfectly fine inside the IDE, but as soon as it's packaged in a jar file, it falls apart. Every file is on the same level and packaged inside the…

mfgravesjr
- 37
- 5
-1
votes
1 answer
How get URL from a file in jar
I need to get the file in my project put a value ( like hello word). But I need to create a jar after:
home
grafica
indice_corrente.txt
finestraprincipale.java
so I access to this file (indice_corrente.txt) in this…

ddd
- 11
- 3
-1
votes
1 answer
Java project with image files
I am working on a project in which I use image files. Where is the proper location to store the folder with the images? Inside src folder (created by netbeans) or outside? Also when I clean and build the project a dist folder is created with the jar…

Thanasis1101
- 1,614
- 4
- 17
- 28
-1
votes
1 answer
getClass().getResource() return null
Hi i am making a quiz application with my project partner and at the end of the quiz i am trying to display an image from out of my resource folders to the winners (a trophy). Everything worked fine untill he tried to run the application on his…

user3485470
- 121
- 5
- 11
-2
votes
1 answer
how to load a resource using Class.getResource()?
I am posting this question because I have not been able to understand what I have to do in order to load a resource file from my java project.
the structure is the following one:
and what I want to do is to load boletinoficial.wsdl file in order to…

bentakayze
- 131
- 1
- 5
- 12
-2
votes
1 answer
FileNotFoundException with FileInputStream even though .getResource(filename) finds it
This is the first question I ask on stackoverflow, so if you notice something unpleasant/bad/inappropriate in my question, please be kind and point it out to me.
I have tried doing my school homework in Java, because I was tired of C++ and I had…
-2
votes
1 answer
Double dot notation no longer works out of classpth (out of bin when using eclipse) for Class.getResouce()?
One common way to load a resource file is using Class.getResource(String name) method, which searches from the classpath of the application.
A FileReader can read from a file even outside of the project folder with double dot notations. For example,…

Jesse Zhuang
- 388
- 1
- 4
- 14
-2
votes
1 answer
Java: NullpointerException by
I get a NullPointerException while running the code below. I don not know why I get it and it keeps me from getting any further in development.
MyImage.java:
import java.awt.Image;
import java.awt.Toolkit;
public class MyImage {
private String…

BlackFool
- 61
- 4
-2
votes
4 answers
Make a static reference to non static field android
I trying to develop an android app, where I need to make a static(PLACES_API_BASE) reference to a non-static variable.Please check out the below code.
private static final String PLACES_API_BASE=…

Dave
- 297
- 3
- 4
- 15
-2
votes
1 answer
getResource doesn't load the image
The image "Pic.jpg" is originally in "C:\Users\qwerty\Documents\NetBeansProjects\SelfTestX\src\Java\image".
It didn't work. I read up on getResource() and it actually reads from where the .class files are stored at.
So, I copied the same image and…

iridescent
- 305
- 4
- 14