| Author |
Distributing apps as jar files
|
Tom McAmmond
Ranch Hand
Joined: Feb 16, 2004
Posts: 58
|
|
This may be a fairly basic question, but it's been puzzling me for a while. If I have a java app that requires: (a) a native Windows dll in to be in the same directory as the app (b) a user-editable configuration/properties file it's not possible to distribute the app as one jar file, is it? RIght now I distribute the app as a jar + those two other files. Which makes it impossible to use, say, Java Webstart, yes? What if the config file becomes editable by the app only, to store persistent configuration data. It still needs to be outside the jar file, right? Would I have to dynamically create the file when the program was first loaded? Please correct me if I'm wrong. And explain, if you have such knowledge! Thanks!
|
 |
Ko Ko Naing
Ranch Hand
Joined: Jun 08, 2002
Posts: 3178
|
|
Originally posted by Tom McAmmond: it's not possible to distribute the app as one jar file, is it? RIght now I distribute the app as a jar + those two other files. Which makes it impossible to use, say, Java Webstart, yes?
Why not? You can bundle all of them into a single jar... If possible, try to use tools to create jar files... It will save your invaluable time in creating and modifying the jars...
What if the config file becomes editable by the app only, to store persistent configuration data. It still needs to be outside the jar file, right? Would I have to dynamically create the file when the program was first loaded?[/QB]
Mmm... I am not quite sure about it... It's more likely that your application has to dynamically create the file when the program was first loaded... Relating to jars, I think Nick might be more expert than me... Let's see if he is available to reply to this thread or not...
|
Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
|
 |
somkiat puisungnoen
Ranch Hand
Joined: Jul 04, 2003
Posts: 1312
|
|
it's not possible to distribute the app as one jar file, is it? RIght now I distribute the app as a jar + those two other files. Which makes it impossible to use, say, Java Webstart, yes?
You can packaged all file in single jar file , When you want to get data from some file (xml, properties file) , you can use this :: And If you want to use JavaWebStart , so MAKE SURE your jar file can be run when you call java -jar myjar.jar.
Would I have to dynamically create the file when the program was first loaded?
If you run app in JavaWebStart, you can not create file when your program was first loaded. Because Default Policy of Security is same applet. but you run your program in normally, so it's work fine ...
|
SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
|
 |
Tom McAmmond
Ranch Hand
Joined: Feb 16, 2004
Posts: 58
|
|
So.... This is still confusing... I have a file called MyJar.jar - within it I have a bunch of classes including com/mydomain/myClass. com.mydomain.myClass has a dependency - a system .dll file must be in the same directory as the program. Isn't "the same directory as the program" on the same directory-level as the jar file? Or if the jar file contains myapp/com/mydomain/myClass so that I can put the dll in the top-level directory myapp, then how do I run it, where does the Manifest file go, and how does the Manifest refer to the Main class? java -jar myapp.com.mydomain.myclass ? I'm still confused about the config file. This program needs to save information in a file. Can a java program dynamically modify the contents of a config file that is inside a jar file? I understand that ican *read* the contents with but can it write to that file too?
|
 |
 |
|
|
subject: Distributing apps as jar files
|
|
|