Questions tagged [getresource]

283 questions
0
votes
1 answer

JAVA getResourceAsStream() real path string interpretation of a file

I am using NetBeans 8.0.2 (I know there already is v8.2 but it has a lot of bugs for me so I got back to v8.0.2) and I need a string path to my .obj file for a parameter attribute like this: api.parameter("filename", "obj/someFile.obj"); Above…
theoneiam
  • 11
  • 6
0
votes
0 answers

background image getResource not working Java

I think i am missing some understanding of the Java getResource() option. The following is my code and I am trying to set a background image. My first approach is working, but for some reasons I need another way to do so. That's why I tried…
maxischl
  • 579
  • 1
  • 11
  • 29
0
votes
1 answer

ProcessBuilder: Start .jar in java package

I try to execute an external jar in my java application. The .jar is in my java-package ("gui"). I tried: String filepath = this.getClass().getResource("ServerRSS.jar").getPath(); ProcessBuilder pb = new…
Sarah Smith
  • 117
  • 1
  • 8
0
votes
1 answer

getResource returns boolean instead String[]

In an IntentService class i want to put some Arrays from Android xml files in an ArrayList, Android-Studio doesnt accept this, but only if i want to add it in an ArrayList. Android Studio says it found a Boolean instead a String[]. But why Boolean?…
cabanni
  • 349
  • 5
  • 12
0
votes
1 answer

Java jar getResource not working in linux

Same lines of code work in Windows but not in Linux. Code is run through a executable jar file. Entries in BuildPath: {PROJECT}/src,{PROJECT}/res Project Path of Test1.java: /src/com/qe/util/Test1 Project Path of TC_Mapping.xml:…
kk.
  • 667
  • 1
  • 15
  • 33
0
votes
0 answers

Get image Embedded Resources in code

Here is my code package test; import javax.swing.*; import static javax.swing.JFrame.EXIT_ON_CLOSE; public class Main { public static void main(String[] args) { JFrame f=new JFrame("Photo"); JLabel p=new JLabel(new…
0
votes
1 answer

MODX: display elements in groups by two with wrapper for every group

Imagine situation when you need to have output like this
First resource Second resource
Third…
0
votes
1 answer

executable jar not opening when used with getResources (but works with an absolute file path) in JavaFX

Problem: Changing two lines of code makes the executable jar go from opening and working perfectly to not opening (even though it runs in Eclipse). Description: I have made an application in JavaFX using local file directories (silly I know) to…
LNern
  • 3
  • 1
0
votes
3 answers

NullPointerException while reading content of BufferedReader although it's not empty

I get a NullPointerException everytime I try to obtain the content of my BufferedReader, when I run the project that is already packed in jar. When it runs inside of IDE (IntelliJ) there's no any problem. I have already checked all previous…
0
votes
0 answers

Android list all files in package

I got a resource package like: com.xxx.res |- res1- | |- a | |- b |- c |- d |- Test.java I want to list all files in package com.xxx.res, the source code of Test.java like below: public static void listRes(File dir) { File[] files =…
Artiano
  • 225
  • 2
  • 11
0
votes
0 answers

.jar file can't access the files within itself

I'm been stuck for a while trying to load images. I've been looking everywhere, but most "solutions" such as .getResource, .getResourceAsStream have not been working for me. Recently I tried looking at the path that the .jar is pulling the file…
Mike
  • 1
  • 1
0
votes
1 answer

Read a resource from a helper class

I am trying to code a helper class with methods that should read a XML file inside my resources folder and get some values on which I will work inside my main class. My project structure looks like this : Project | |---src | | | …
0
votes
1 answer

How can I use a variable to define a file for InputStream / .getResourceAsStream(variableForTextFiles) in Java?

Right now I have a text file for this to read hard-coded as KlebsiellaMicro.txt. What I need is a variable, fileName, to dynamically pull in a different txtfile name based on the template selection in a different java file. Under the file…
0
votes
1 answer

Loading Images from resource or different folders

I create a custom class that extends ImageIcon, so that passing the file url and a given color, it loads the image repainting it. This class is packed in a .jar file I use for developing different user interfaces (let's call it UI.jar). This class…
Roberto
  • 243
  • 1
  • 5
  • 15
0
votes
2 answers

How to use getClass and getResource?

Here's the error I am getting: Using directory file:/D:/CCSF%20Docs/CS111B/Java%20Projects/LabelDemo2.java/bin/ Image url is null Exception in thread "main" java.lang.NullPointerException at javax.swing.ImageIcon.(Unknown Source) …
tekamts
  • 1
  • 1