• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Get me the mayor's office! I need to tell him about this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic