Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access to resources via ClassLoader interacts with java-to-exe products

 
Daniel B. Davis
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A recurring problem is access to resources. If the host operating system is Windows, one type of filepath works; if Linux, a different one works. The solution offered by Java appears to be ClassLoader, in which, as I understand it, the resource is placed somewhere in the classpath, after which the operation classLoader.getResourceAsStream(resource_name); obtains the resource ready to be read as a stream.

In an application, I have successfully used it and the application works under both 'java' and 'javaw' commands. Then I wanted to use a java-to-exe program so that my infrequent users need not download and install the JRE. The first step of the process is to get the thing to work at all under the java-to-exe software, after which I would attack bundling it up.

I chose Winrun4j, and the program starts successfully under it. All normal program functions work, since they do not depend upon anything external, but the following depends upon locating resources using the ClassLoader:
o The HelpSet, upon which the Help system is based
o Log4j Properties, upon which logging is based.
o The About text for the About box.
These do not work.

It may be possible to repackage things for Winrun4j so that these dependencies are added separately and explicitly, and to add command-line arguments to convey the information to the program, but it is inelegant and clumsy, and undoes the good design of ClassLoader. Plus it would need changing when transitioning between Windows, Linux, other operating systems.

A further note: I looked for a way to ask the folks at WinRun4J about this, but although they have a blog, I cannot find how to post to it, or reach them in any other way. So if there is no direct WinRun4J knowledge available, even a way to contact them would be useful.

Any and all ideas or corrections of understanding are gratefully appreciated.
 
Rob Spoor
Sheriff
Pie
Posts: 20532
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not GUI related. Moving to Java in General.
 
Daniel B. Davis
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have found my answer: Classpath had not been set. Sorry to waste everyone's time with this. How may I withdraw the prior post as well as this one?

Thanks much. Having Javaranch is sometimes as good as talking it out to a colleague; sometimes better.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48981
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel B. Davis wrote: . . . How may I withdraw the prior post as well as this one?
You don't. This discussion might be useful for somebody else in future.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic