Win a copy of Create an Uber Clone in 7 Days: Build a real world full stack mobile app in Java this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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
 
We cannot change unless we survive, but we will not survive unless we change. Evolving tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!