This week's book giveaway is in the Android forum.
We're giving away four copies of Learning Java by Building Android Games and have Jean-Marcel Belmont on-line!
See this thread for details.
Win a copy of Learning Java by Building Android Games this week in the Android forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Using library inside a Jar  RSS feed

 
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • 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
  • 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
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • 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
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!