• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

packaging the runme.jar

 
Yupp Cook
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!

In my spec for B&S 2.1.2 I find some controversal "musts". Enligtening is welcome!

1.
"Data.java", must be in a package called "suncertify.db",

2.
All source and class-files must in the directory "code".
...

3.
Starting everything with
java -jar runme.jar [mode]


The problem:
According to 1. my package structure is
suncertify.db.*
suncertify.server.*
suncertify.client.*
suncertify.logic.*

According to 2. all the files are in the folder "code"

I start the unpacked app from the root directory with
java -classpath code BS_Start [mode]. No problem!

But how to start the packed runme.jar
java -jar runme.jar [mode] complains about not beeing able to find BS_Start! Of course it's in the directory "code". When Calling a jar there's no way defining a classpath.
(Jared with jar cvfm runme.jar META-INF/MANIFEST.MF *.*)

When I moove root:\code\suncertify... to root:\suncertify...
it works well, but then the 2. must is hurt.

Am I doing sth. wrong?

Thanx
Yupp
 
Yupp Cook
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manifest.mf is:

Manifest-Version: 1.0
Created-By: 1.4.2_06 (Sun Microsystems Inc.)
Main-Class: suncertify.BS_Start
 
Ed Tse
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, when they ask you to put source into code,it doesn't mean your jar has to be packaged with code directory in it. Just treat your 'code' directory as your source root for your project.

let's say your have
c:\SCJD\code\suncertify\db

You should not go to c:\SCJD and do jaring there, but you should go to c:\SCJD\code\ to perform the jarring for the runme.jar. However, when you submit your whole project, you should go to c:\SCJD and zip up the whole directory into a jar.

The jar that you will submit should contain your executeable jar!.
 
Yupp Cook
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Ed
So to say a jar in a jar
 
Lee Sunter
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ed Tse,
Does that mean that you have to run your jar from a directory called \SCJD as I appear to have to, because it cant find my properties file?
This is possibly an error with my coding as I just do
File f = new File("code\\suncertify.properties");
Properties properties = new Properties();
DataInputStream dis = new DataInputStream(new FileInputStream(f));
properties.load(dis);
so I supose this is wrong as its looking for my properties file under the directory stucture and not in my jar? (does that make sense) how do you fix that? ie its looking at the under the sturcture of \SCJD\code\suncertify.properties hence it will only work if that exists.
Any suggetsions on how to solve this problem?
Thanks
Lee
 
Ed Tse
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way you code is to load a property file relative to where vm is launched. I don't think that's a proper way because the examiner could theortically launch your jar anywhere.

Take a look at http://www.javaworld.com/javaworld/javaqa/2003-08/01-qa-0808-property.html
See if this relates to what you want.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic