• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

Packaging & moving

I have two directories

.\oneapp
.\common

Classes in oneapp import the package common (which is imported obvisously by other apps as well.

Now I want to move oneapp to run elsewhere. I jar everything there and take it.

java -classpath oneapp.jar;common.jar mymain will not do the job. Not even if I put the un-jarred common classes in a \common directory.

What am I doing wrong??
0
piou
Asked:
piou
  • 6
  • 4
  • 4
  • +1
1 Solution
 
cheekycjCommented:
have you tried:
java -cp common.jar -jar oneapp.jar mymain

CJ
0
 
piouAuthor Commented:
Um, actually I am running on PersonalJava, the JVM is called 'evm' and the -jar option is not supported.
0
 
cheekycjCommented:
try this:
java -classpath "oneapp.jar;common.jar" mymain

CJ
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
CEHJCommented:
oneapp classes and common classes should be in the same jar
0
 
The_ChiefGeekCommented:
when you build the jar file for oneapp and common are u including the oneapp and common dirs?  If there not part of the package name then u shouldn't.  ie if your classpath was set to oneapp;common then when you build the jar file do it like this:

jar cvf oneapp.jar -C oneapp .
jar cvf common.jar -C common .
0
 
The_ChiefGeekCommented:
from reading a little closer it looks like oneapp has no package and common is a package.  so build the jars like this.
jar cvf oneapp.jar -C oneapp .
jar cvf common.jar common
0
 
piouAuthor Commented:
Chief, I'm pasting some output. JAR doesn't exactly do the job.

C:\WORK\PROJ\JWACommon>jar cvf JWACommon.jar -C JWACommon/ *.class
JWACommon\BadInputException.class : no such file or directory
added manifest
adding: BadPacketException.class(in = 312) (out= 223)(deflated 28%)
adding: JWAException.class(in = 297) (out= 214)(deflated 27%)
adding: Packet.class(in = 2550) (out= 1452)(deflated 43%)
adding: PacketTypes.class(in = 918) (out= 559)(deflated 39%)

C:\WORK\PROJ\JWACommon>
0
 
CEHJCommented:
If you want to move this around and run it elsewhere, why are you not putting common and oneapp in the same jar?
0
 
piouAuthor Commented:
CEHJ,

This won't work because classes in 'common' belong to a defined package.

It's tricky the package business. I have grapsed it as far as class files concern, but when JARing... I lose it!

0
 
CEHJCommented:
>>classes in 'common' belong to a defined package

Do you mean one not created by yourself? If so, are other packages using it too?
0
 
piouAuthor Commented:
No, I mean that classes in common belong to their package by having the line "package ..." in source. So when compiled they appear as that particular package. I also tried it to be 100% sure :)

0
 
CEHJCommented:
OK. I think i get the picture now!

Can you verify that you can run your application using the common.jar *before* you move it? Make sure where X.class exists in common.jar it doesn't also exist outside the jar file (rename X.bak if necessary)
0
 
piouAuthor Commented:
Oh! I've made a mess now with sources' version! :(
I'll get back as soon as I sort this out.
0
 
The_ChiefGeekCommented:
As i stated above use the following command line when building your jar files!

# This first one includes everything in the oneapp dir, but not the oneapp dir itself ( oneapp is not a package name ).
jar cvf oneapp.jar -C oneapp .

# this one builds the jar file for the package called common.
jar cvf common.jar common
0
 
piouAuthor Commented:
Indeed was the C switch. Although I still don't understand why it didn't work the first times. Thanks.
0
 
The_ChiefGeekCommented:
piou,

When u use the -C option that simply tells the jar cmd to cd to that dir, then you have to tell it what to put in the jar.  *.class would only be all the class files in that dir ( no sub dirs included ).  I ussualy just use "." to get the entire dir and sub dirs.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 6
  • 4
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now