• 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

Adding a class to a .jar file

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a desktop app and I want to load class files from my server and load them into the app. I can dynamically load the class, but I'm having class path issues when I compress the app into a .jar. I tried starting the app like this:

java -cp /dir_where_downloaded_classes_are -jar /the_app.jar

but it's not working. Is it possible to programatically add .class files to a .jar file at runtime without the JDK (on an arbitrary person's computer)? Any other ideas would be appreciated.

Thanks!
[ June 10, 2006: Message edited by: Ned Smith ]
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no point in specifying "-cp anything" when you use the "-jar something.jar" option on your command line. Only the "-jar" part is used, the "-cp" part is ignored. That's because the jar file contains its own classpath, in its manifest. You could have the manifest file name that directory as part of the classpath, though.

And no, you can't add anything to a jar file once it has been created. Whether you have a JDK or not.
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can in fact add things to a jarfile quite easily. The jar command contains functionality to do just that.

But doing that the way the OP suggests is at the very least a sign of very bad design.
It reeks of virusses injecting their own functionality into existing software, especially as he wants it to be invisible to the victim/user.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic