?
Solved

Packaging & moving

Posted on 2003-02-27
16
Medium Priority
?
151 Views
Last Modified: 2010-03-31
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
Comment
Question by:piou
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 4
  • +1
16 Comments
 
LVL 19

Expert Comment

by:cheekycj
ID: 8035729
have you tried:
java -cp common.jar -jar oneapp.jar mymain

CJ
0
 

Author Comment

by:piou
ID: 8035865
Um, actually I am running on PersonalJava, the JVM is called 'evm' and the -jar option is not supported.
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 8035980
try this:
java -classpath "oneapp.jar;common.jar" mymain

CJ
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:CEHJ
ID: 8036328
oneapp classes and common classes should be in the same jar
0
 

Expert Comment

by:The_ChiefGeek
ID: 8036845
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
 

Accepted Solution

by:
The_ChiefGeek earned 200 total points
ID: 8036863
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
 

Author Comment

by:piou
ID: 8037859
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 8037921
If you want to move this around and run it elsewhere, why are you not putting common and oneapp in the same jar?
0
 

Author Comment

by:piou
ID: 8038070
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 8038084
>>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
 

Author Comment

by:piou
ID: 8038270
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 8038303
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
 

Author Comment

by:piou
ID: 8038432
Oh! I've made a mess now with sources' version! :(
I'll get back as soon as I sort this out.
0
 

Expert Comment

by:The_ChiefGeek
ID: 8042344
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
 

Author Comment

by:piou
ID: 8046296
Indeed was the C switch. Although I still don't understand why it didn't work the first times. Thanks.
0
 

Expert Comment

by:The_ChiefGeek
ID: 8082804
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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month8 days, 21 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question