Menu
  • HOME
  • TAGS

JButton.setIcon throws null pointer when file exists

java,swing,nullpointerexception,embedded-resource,getresource

OK, I figured out what was going on. Three things to fix this. First of all, I realized that the null problem was not the icon I was trying to put on the button, it was a misplaced JButton call at the top in the CreateGUI method. I removed that...

Java: NullpointerException by

java,image,classloader,getresource

Null pointer Error you are facing should be at this line img = Toolkit.getDefaultToolkit() .createImage(getClass() .getClassLoader() .getResource(name)); This is because it could not find the file Flower.jpg. When u give getClassLoader().getResource(name), it looks for the img folder in root directory where class files are located. You can see the below...

Android Studio can't find Resuorces

java,android,android-studio,runtime-error,getresource

You have not initialised your adapter namely "klassen_adapter" in your main activity. It's null and invoking any method on it will be null pointer exception

getClass().getResource() in static context

java,url,static,getresource

Remove the ".getClass()" part. Just use URL u = StaticResource.class.getResource("image.png"); ...

ModX getResources template chunk HTML out of order?

modx,modx-revolution,getresource,modx-chunks

It was a weird issue with wrapping a block element (div) in an inline a tag. Changed div to span and it was ok.

Output Multiselect TV by getResource in modx revo

multi-select,modx-revolution,getresource

Set commma as custom output type of your tv:

getResource causing NullPointerException

java,getresource

Klass.class.getClass() is equivalent to Class.class, since the class of Klass.class is Class. So this would be trying to load a resource in the java.lang package. You just want Klass.class.getResource().

ModX revo 2.2x: How to use a TV value to set tpl?

php,content-management-system,modx-revolution,getresource

If you need to do major changes to the html you could still probably solve it with css if you have a nice markup. However if thats not enough i would solve it by using one tpl for the getresources call, and letting that tpl handle the switching. If you...

Why does getResource return null

java,eclipse,jar,assets,getresource

There are lot of ways to add a resource to the jar file, you can put it in src, add as a resource if you use maven, ant etc... If you able to bundle whole directory then you should be able to use your original piece of code. With the...

getResourceAsStream() returning null

java,android,jar,getresource

getResourceAsStream() isn't terribly useful in android. It refers to files embedded in a JAR or classpath container, not android Resources. You probably want to use the android assets feature instead. You can simply place the asset file ("data.txt") under your project's assets/ directory. To get an InputStream for the asset,...

JavaFX getResource return null when running in browser

java,javafx,javafx-2,classpath,getresource

I resolved this problem myself. The root cause is that I did not sign my jar properly. Java getResource() use reflection which will not execute correctly without as valid certificate. A self-signed jar will be fine in this case. Thanks for every input above as well. ...

NetBeans getting resource inside JAR file?

java,netbeans,getresource

Can anyone point me in the right direction as to how i correctly get a resource? Presuming the resources are within the created jar file, you can define the path as absolute relative to the package root: clipNameAIS = AudioSystem.getAudioInputStream(getClass().getResourceAsStream("/overtimesystem/Sounds/Cat.wav")); Note the / at the beginning, defining the path...

Getting location of file as string in resource folder

java,resources,getresource

Resources, when you deploy your software, are not deployed as files in a folder. They are packaged as part of the jar of your application. And you access them by retrieving them from inside the jar. The class loader knows how to retrieve stuff from the jar, and therefore you...