Results 1 to 11 of 11
- 01-07-2012, 02:29 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 7
- Rep Power
- 0
ClassLoader.getSystemResource() returns null
Hi,
as mentioned in the title:
when I use this, iconURL returns null.Java Code:URL iconURL = ClassLoader.getSystemResource("img/bird.gif");
I have a folder img in my project where bird.gif is in.
Can someone help my with this issue please?
Regards
SvenLast edited by SVENeRGy; 01-07-2012 at 02:31 PM.
- 01-07-2012, 02:32 PM #2
Re: ClassLoader.getSystemResource() returns null
Is the folder that contains the img folder on the classpath?
Last edited by Norm; 01-07-2012 at 02:38 PM. Reason: added contains
- 01-07-2012, 02:34 PM #3
Member
- Join Date
- Jan 2012
- Posts
- 7
- Rep Power
- 0
Re: ClassLoader.getSystemResource() returns null
Hi,
thanks for answering so fast.
it is added as class folder in libraries. I hope this is correct.
This doesn't do the trick
- 01-07-2012, 02:36 PM #4
Re: ClassLoader.getSystemResource() returns null
What folders are on your classpath? Is the folder containing the img folder on the classpath when you execute your program?
- 01-07-2012, 02:41 PM #5
Member
- Join Date
- Jan 2012
- Posts
- 7
- Rep Power
- 0
Re: ClassLoader.getSystemResource() returns null
folder img
and system library
- 01-07-2012, 02:43 PM #6
Member
- Join Date
- Jan 2012
- Posts
- 7
- Rep Power
- 0
Re: ClassLoader.getSystemResource() returns null
added the images to a jar file, and added the jar file to the libraries. Now it works.
- 01-07-2012, 02:44 PM #7
Re: ClassLoader.getSystemResource() returns null
You're not answering the question about what folders are on the classpath.
Get the System Properties and display them to show the classpath's contents.
- 01-07-2012, 02:54 PM #8
Member
- Join Date
- Jan 2012
- Posts
- 7
- Rep Power
- 0
Re: ClassLoader.getSystemResource() returns null
I hope this is what you have been asking for.
java.class.path now = /Users/sven/Documents/workspace/Boek2Hoofdstuk03/bin:/Users/sven/Documents/workspace/Boek2Hoofdstuk03/img
regards
Sven
- 01-07-2012, 02:57 PM #9
Re: ClassLoader.getSystemResource() returns null
The folder containing the img folder should be on the classpath:
the classpath + the path in the call to getSystemResource() should be the full path to the resource.
The way you have it would be like this with two img folders:
/Users/sven/Documents/workspace/Boek2Hoofdstuk03/img/img/bird.gif
- 01-07-2012, 02:58 PM #10
Member
- Join Date
- Jan 2012
- Posts
- 7
- Rep Power
- 0
Re: ClassLoader.getSystemResource() returns null
{java.runtime.name=Java(TM) SE Runtime Environment, sun.boot.library.path=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries, java.vm.version=20.4-b02-402, awt.nativeDoubleBuffering=true, gopherProxySet=false, mrj.build=11M3527, java.vm.vendor=Apple Inc., java.vendor.url=http://www.apple.com/, path.separator=:, java.vm.name=Java HotSpot(TM) 64-Bit Server VM, file.encoding.pkg=sun.io, sun.java.launcher=SUN_STANDARD, user.country=NL, sun.os.patch.level=unknown, java.vm.specification.name=Java Virtual Machine Specification, user.dir=/Users/svendobbels/Documents/workspace/Boek2Hoofdstuk03, java.runtime.version=1.6.0_29-b11-402-11M3527, java.awt.graphicsenv=apple.awt.CGraphicsEnvironmen t, java.endorsed.dirs=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/endorsed, os.arch=x86_64, java.io.tmpdir=/var/folders/0y/d9znkpt160x6l_j9lwtjc1pr0000gn/T/, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., os.name=Mac OS X, sun.jnu.encoding=MacRoman, java.library.path=.:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java, java.specification.name=Java Platform API Specification, java.class.version=50.0, sun.management.compiler=HotSpot 64-Bit Tiered Compilers, os.version=10.7.2, http.nonProxyHosts=local|*.local|169.254/16|*.169.254/16, user.home=/Users/svendobbels, user.timezone=, java.awt.printerjob=apple.awt.CPrinterJob, file.encoding=MacRoman, java.specification.version=1.6, java.class.path=/Users/svendobbels/Documents/workspace/Boek2Hoofdstuk03/bin:/Users/svendobbels/Documents/workspace/Boek2Hoofdstuk03/img, user.name=svendobbels, java.vm.specification.version=1.0, sun.java.command=sven.dobbels.SwingUtils.GetClassP ath, java.home=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home, sun.arch.data.model=64, user.language=nl, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=apple.awt.CToolkit, java.vm.info=mixed mode, java.version=1.6.0_29, java.ext.dirs=/Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext, sun.boot.class.path=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsfd.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Resources/Java/JavaRuntimeSupport.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/ui.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/laf.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/sunrsasign.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsse.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jce.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/charsets.jar, java.vendor=Apple Inc., file.separator=/, java.vendor.url.bug=http://bugreport.apple.com/, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, mrj.version=1070.1.6.0_29-402, socksNonProxyHosts=local|*.local|169.254/16|*.169.254/16, ftp.nonProxyHosts=local|*.local|169.254/16|*.169.254/16, sun.cpu.isalist=}
- 01-07-2012, 03:06 PM #11
Member
- Join Date
- Jan 2012
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
ArrayList returns null
By aborgeld in forum New To JavaReplies: 6Last Post: 04-01-2011, 01:32 PM -
XML and SAX - class returns 'null'
By Laffel in forum Advanced JavaReplies: 2Last Post: 03-07-2011, 09:14 PM -
Splashscreen returns null
By Charlie161 in forum AWT / SwingReplies: 2Last Post: 03-04-2011, 01:25 PM -
getImplementationVersion() returns null
By newbiejava in forum New To JavaReplies: 22Last Post: 09-12-2010, 09:31 AM -
helpset findHelpSet returns null
By kmm1977 in forum AWT / SwingReplies: 23Last Post: 06-22-2010, 03:53 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks