• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Using library inside a Jar

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all.
I have developed a swing application and package it into executeable jar.
I have the following structure :
-------------------------------------
currentdir\com\*.class // dir for all class files
currentdir\images // dir for all images
currentdir\lib\kunststoff.jar // dir for kunststoff L&F
-------------------------------------
I want my application to use the kunststoff L&F, so :
how to use this L&F with my application ? and what should I put
inside the main class of my application (I know how to use UIManager.setLookAndFeel( )) and I don't mean it).
I think , I should use the class loader to access this jar, but how??
(please, you will help me very much if you give the important lines of code)
thank.
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why wouldn't you just put the jar on the classpath to access the classes?
Joe
 
Hussein Baghdadi
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because when I have packeged my app in an executable jar, my application uses the default L&F and not the Kunststoff
 
Joe Gilvary
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please forgive me if I'm being dense, but when your jar is on the classpath, can you not call UIManager.setLookAndFeel(packages.to.Kunststoff.KLookAndFeel) or some such? I have never built a custom look and feel, so maybe I just don't understand the problem.
If you have to have the ClassLoader, try getClass().getClassLoader() and use that to load the L&F class directly. If the classpath setting is insufficient to make the classes visible, try using the util.jar.JarFile to read a stream of bytes and ClassLoader.defineClass() from that.
Thanks,
Joe
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic