Win a copy of Kotlin for Android App Development this week in the Kotlin 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Using library inside a Jar  RSS feed

 
clojure forum advocate
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
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 count your weasels before they've popped. And now for a mulberry bush related tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!