delivering a program as multiple .jar files


D

David Lamb

I am building a program that logically consists of three separate groups
of classes, which I'd prefer to store as 3 separate .jar files.

a) Those from a generic library (written by group 1)

b) Those that implement a specific program on top of the library
(written by group 2, potentially different from group 1). This contains
the main class.

c) Those that represent a set of mods to the specific program (written
by group 3, likely different from groups 1 and 2). I expect that one of
the inputs or parameters to the main program will give strings that can
be turned into names of classes that the main program can pass to a
class loader to somehow tie these mods into the program.

I'm trying to figure out good ways to organize these groups of classes.
I know group 3 could just combine all 3 .jar files and provide its own
manifest identifying one of its own classes as the main class, but I'd
prefer to leave the main program in control.

I'm thinking of three possible scenarios, and don't know how to
implement any of them; I'd like to know how to do all 3 (if #3 is
possible at all):

1) The user (likely somebody not from any of the above 3 groups)
downloads all 3 .jar files, and runs the group by invoking the main .jar
file (b), supplying some parameter that identifies the mod (c).

2) The user invokes the mod via a link to a .jnlp file, which somehow
acquires all 3 .jar files from a single site. In this mode they might
view the program as a "demo" that has very restricted access to the
user's system, but can at least store some form of data between
invocations (I realize there are JWS packages that I need to investigate
that should accomplish some of this, but so far I've only used JWS to
invoke single .jar files that need no access to the user's system).

3) The user invokes the main program via JNLP, but with the mod from
some second site. I realize that by default this is impossible but
wondered if there is a way to ask for user permission to do this. If
it's possible, how can the main program locate the second .jar file?

There are security concerns in the back of my mind that I can explain if
it seems relevant to answering the question -- basically, I'd expect
users to "trust" segments (a) and (b) more than they do (c) and might be
willing to grant special permissions if they could believe (b) is "in
charge" of anything risky.
 
Ad

Advertisements

A

Arne Vajhøj

David said:
I am building a program that logically consists of three separate groups
of classes, which I'd prefer to store as 3 separate .jar files.

a) Those from a generic library (written by group 1)

b) Those that implement a specific program on top of the library
(written by group 2, potentially different from group 1). This contains
the main class.

c) Those that represent a set of mods to the specific program (written
by group 3, likely different from groups 1 and 2). I expect that one of
the inputs or parameters to the main program will give strings that can
be turned into names of classes that the main program can pass to a
class loader to somehow tie these mods into the program.

I'm trying to figure out good ways to organize these groups of classes.
I know group 3 could just combine all 3 .jar files and provide its own
manifest identifying one of its own classes as the main class, but I'd
prefer to leave the main program in control.

I'm thinking of three possible scenarios, and don't know how to
implement any of them; I'd like to know how to do all 3 (if #3 is
possible at all):

1) The user (likely somebody not from any of the above 3 groups)
downloads all 3 .jar files, and runs the group by invoking the main .jar
file (b), supplying some parameter that identifies the mod (c).

2) The user invokes the mod via a link to a .jnlp file, which somehow
acquires all 3 .jar files from a single site. In this mode they might
view the program as a "demo" that has very restricted access to the
user's system, but can at least store some form of data between
invocations (I realize there are JWS packages that I need to investigate
that should accomplish some of this, but so far I've only used JWS to
invoke single .jar files that need no access to the user's system).

3) The user invokes the main program via JNLP, but with the mod from
some second site. I realize that by default this is impossible but
wondered if there is a way to ask for user permission to do this. If
it's possible, how can the main program locate the second .jar file?

There are security concerns in the back of my mind that I can explain if
it seems relevant to answering the question -- basically, I'd expect
users to "trust" segments (a) and (b) more than they do (c) and might be
willing to grant special permissions if they could believe (b) is "in
charge" of anything risky.

If it is a desktop style app I would suggest:
- b.jar with Main-Class directive and a Class-Path directive
pointing to a.jar
- a.jar in same dir
- a config file specifying jar file and module name
- URLClassLoader to load the modules
- a security manager if needed

Arne
 
D

David Lamb

Arne said:
If it is a desktop style app
Yes.

I would suggest:
- b.jar with Main-Class directive and a Class-Path directive
pointing to a.jar
- a.jar in same dir
- a config file specifying jar file and module name
- URLClassLoader to load the modules
- a security manager if needed

Thanks! The Class-Path directive and URLClassLoader were two things I
didn't know about.
 
R

Roedy Green

I am building a program that logically consists of three separate groups
of classes, which I'd prefer to store as 3 separate .jar files.

there are two basic approaches, using Java Web Start and a JNLP file
to describe the aux jars, and a
Class-Path: myplace/myjar.jar . myplace/other.jar jardir/
in the jar manifest

see http://mindprod.com/jgloss/jar.html
http://mindprod.com/jgloss/javawebstart.html
--
Roedy Green Canadian Mind Products
http://mindprod.com

"We must be very careful when we give advice to younger people: sometimes
they follow it!"
~ Edsger Wybe Dijkstra, born: 1930-05-11 died: 2002-08-06 at age: 72
 
Ad

Advertisements

A

Andrew Thompson

..
2) The user invokes the mod via a link to a .jnlp file, which somehow
acquires all 3 .jar files from a single site.  In this mode they might
view the program as a "demo" that has very restricted access to the
user's system,

If the app. needs to open/save files, it can do
so from within the sandbox, by using the JNLP API.
See the FileOpen/Save service demo(1) for more details.
(1) <http://pscode.org/jws/api.html#fs>

Having said that..
..but can at least store some form of data between
invocations (I realize there are JWS packages that I need to investigate
that should accomplish some of this,

...that is easy in JWS, even for a fully sandboxed app.
See the PersistenceService demo(2) for details.
(2) said:
..but so far I've only used JWS to
invoke single .jar files that need no access to the user's system).

It's time to explore the further possibilities of
web start (IMO). JWS is well suited to supplying
everything this app. requires (as far as I understand).

Perhaps your users would also enjoy some other
things JWS offers, like..
- A desktop shortcut or menu item for the app.
- Lazy download of Jars (ensures they get only what
they need)
- Automatic update of Jars (and only whichever Jars
have been updated)
- The ability to deploy different parts of the app.
with different security levels (a sandboxed main
app. might use an all-permissions API).
- ..
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top