Questions tagged [getresource]

283 questions
3
votes
1 answer

Why does getResourceAsStream() not work in JAR files?

I have the following code in a static method: clips.open(AudioSystem.getAudioInputStream(Sound.class.getResourceAsStream("folder/sound.wav"))); Also, folder is in the same directory as Sound.java. When I run the program in Eclipse, the sound is…
null
  • 2,060
  • 3
  • 23
  • 42
3
votes
1 answer

Properties file could not be found by getResourceAsStream(). Check the CLASSPATH or class loader

This is from an open source project where there is nearly no support. Compilation of the project went well. But I cannot test or install because of a particular property file cannot be found. I have search up and down the internet and not able to…
Kemin Zhou
  • 6,264
  • 2
  • 48
  • 56
3
votes
1 answer

Write java resource in src directory

I am making a (tile)level editor using java and eclipse as IDE. I am using getResourceAsStream to load tilemap. And this code to write map back. URL resourceUrl = getClass().getResource(FILENAME); File file = new…
AvrDragon
  • 7,139
  • 4
  • 27
  • 42
3
votes
0 answers

Using StandardLocation Class in Annotation processor

I am using NETBeans IDE for developing an annotation processor. I have written the annotation processor and then convert it to a JAR and then add this JAR as a referenced library to another java application where i am using the annotations. Now my…
yash6
  • 141
  • 3
  • 14
3
votes
3 answers

getDrawable returning null

Since i've busted my last question regarding this matter due to posting a different code from the one regarding the problem i'm going to try again with the right code... So here's the deal, I've been running some tests with GoogleMaps API for…
thiagocfb
  • 487
  • 1
  • 9
  • 19
2
votes
1 answer

C, open files relative to executable's path?

I want to fix an old C program (got the source) that uses relative paths to load data files, expecting the executable is called from the directory where it is placed, such as LoadEx("./dataFile", dataFile); Of course calling the program from another…
juanmirocks
  • 4,786
  • 5
  • 46
  • 46
2
votes
1 answer

How to specify resource location in the same way when compiling TO and NOT TO a JAR file

I have a project that I am compiling using javac. I want to be able to fetch resources without having to first build my project into a JAR file, but at the same time, I don't want to hard code the location either (C://Users/name/etc). I know that if…
davidalayachew
  • 1,279
  • 1
  • 11
  • 22
2
votes
5 answers

Accessing resources locally in an applet on IE6

Was trying to follow http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html when came across error. Seems that getResource returns null when accessing the page locally (i.e., when URL is, say, "C:\projects\html\test.html") in IE6. …
2
votes
0 answers

Locale Changed, but String Resources are not updating

I have a problem in changing locale, I have tried this https://stackoverflow.com/a/40704077/2199589 and the following snippet with both BaseContext and ApplicationContext, none of them works well. I have saved the current language in share…
2
votes
3 answers

cannot resolve method getResource().getColor() error

I am trying to change text color in java code (I dun want to change it at xml)and I know i need to call getResource(). but I get error that "cannot resolve method getResource()". and i try to declare Context and use context to call getResource() and…
Wang Jian
  • 321
  • 5
  • 20
2
votes
1 answer

Access from ejb from child jar to parent ear sources in maven project

I have a simple task, but can't make it correct. I have one java maven project. This project builded in EAR, that consist of JARs and WARs. I have a bean in one of these child jars, which should get Resource from parent EAR from…
JaVanna
  • 113
  • 5
2
votes
0 answers

Java/Eclipse - getClass().getResource(...) is returning null

When executing following code, imgURL is always set to NULL: try { URL imgURL = getClass().getResource("assets/image.png"); System.out.println(imgURL); BufferedImage sheet = ImageIO.read(imgURL); } catch (IOException e) { …
2
votes
2 answers

java how to add image using getResource()?

I want to add an image to a Jpanel Class, I use the method getResource() but it returns Exception in thread "main" java.lang.IllegalArgumentException: input == null!, because the path into the image folder that i give is not valid, now I want how to…
cbInfo009
  • 71
  • 1
  • 4
  • 14
2
votes
2 answers

getResourceEntryName() :can i manage to get "R.id.+getresourceentryname(R.string.myString)"?

im trying to resolve the following problem : i named my string resource like that in my xml string file : Nature Architecture
Noj
  • 164
  • 1
  • 15
2
votes
2 answers

Overriding a resource contained in a jar file

I am running a tool (a virtual globe) through code from a jar file. The code reads a resource (an XML file) to provide some configuration options, using syntax like this, in a method of class Config: URL localURL =…
Albert Godfrind
  • 1,978
  • 1
  • 12
  • 20