?
Solved

[URGENT] JAR Files

Posted on 2006-12-01
29
Medium Priority
?
216 Views
Last Modified: 2013-11-23
Hi,

I have a JAR file, and in it, the classes are compiled in Java 1.5,
the problem is ... that I need them to run in Java 1.4 ...

I have the sources of the classes,
so I have compiled them into 1.4, that's fine.

In the JAR there is
- some ressources
- classes

How can I replace the 1.5 classes located in the jar with the 1.4 classes I have.
0
Comment
Question by:matthew016
  • 12
  • 8
  • 8
  • +1
29 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 800 total points
ID: 18053514
0
 
LVL 9

Author Comment

by:matthew016
ID: 18053556
But I don't have some ressources,

just as example I see a file with .LIST extension,

well if I re-create a JAR I can't include this one because I don't know from where it came.
0
 
LVL 35

Expert Comment

by:girionis
ID: 18053576
You have the resources inside the jar file. Everything you need is there. If you need more resources then just include them when you are creating the jar again.
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 35

Expert Comment

by:girionis
ID: 18053588
> just as example I see a file with .LIST extension,

>well if I re-create a JAR I can't include this one because I don't know from where it came.

If it is in the jar already then you need it. You should not be bothered from where this file came from, if it is there you probably need it and it would be good to have it included inside your new jar. Otherwise you might be missing some resources essential to the jar and it won't function as expected.
0
 
LVL 35

Expert Comment

by:girionis
ID: 18053593
But, as a side not, if you have the source code you should also have the resources as well.
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 18054043
May I presume that those other files are no class files and thus JAVA version independent?

;JOOP!
0
 
LVL 9

Author Comment

by:matthew016
ID: 18054087
Ok, so I'll make a JAR of the classes,
how do I put the ressources in it ?
0
 
LVL 9

Author Comment

by:matthew016
ID: 18054091
sciuriware >> All classes need to be replaced, the other things are ressources like a Manifest file and a .LIST file.
0
 
LVL 24

Assisted Solution

by:sciuriware
sciuriware earned 800 total points
ID: 18054219
Use the jar.exe command from the commandline.

type:              jar

for all options.

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 18054228
That reveals that you could have replaced the .class files in the old jar

;JOOP!
0
 
LVL 9

Author Comment

by:matthew016
ID: 18054260
What ?

Ok I'll create a Jar of my classes,

I just want to know how I can, when the Jar is created, add the ressource in it ?

0
 
LVL 24

Expert Comment

by:sciuriware
ID: 18054323
With the same command: jar.exe doesn't bother what files you insert.
You could as well add sources or pictures.
Just one warning: do this first:

jar -tvf <your old .jar file>

to see what was in it and where.

;JOOP!
0
 
LVL 9

Author Comment

by:matthew016
ID: 18054606
jar is not recognized and I can't change path variables due to restrictions on the machine.
what's the .exe to execute the command ?
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 18054880
Path: of course you can:

Start->Run->cmd                 black MSDOS window

CD .......                               go to the right directory/folder
SET PATH=C:\PROGRAM FILES\JAVA\JRE1.5.0_09\BIN;%PATH%           or where your JAVA distribution is ....
JAR

see the explanation.

;JOOP!

0
 
LVL 9

Author Comment

by:matthew016
ID: 18054910
I can also just open it in Winrar ....
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 18054933
If only you produce a .jar, which is, by the way, a .zip file.

You maybe better use Winzip on it. I never tried that because I use Totalcommander.
May be you must temporarily rename the .jar to .zip and afterwards rename it back.
Anyway, Winzip keeps you in control of what you're doing.

;JOOP!
0
 
LVL 9

Author Comment

by:matthew016
ID: 18055081
Ok I tried to put the bin dir in the path
but when I do jar, it is not recognised
not sure I have the program
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 18055453
Sorry, sorry, I meant:

SET PATH=C:\PROGRAM FILES\JAVA\JDK1.5.0_09\BIN;%PATH%

Because jar.exe is only distributed with the development kit JDK

Verify for yourself that jar.exe is there.

;JOOP!
0
 
LVL 35

Expert Comment

by:girionis
ID: 18060033
> Ok, so I'll make a JAR of the classes,
>how do I put the ressources in it ?

Have a look at the link I posted, it explains how you can use the jar command.
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 18062308
A .jar file can be updated in several ways, but remember to list the contents
of the original .jar like I said several posts back.

;JOOP!
0
 
LVL 10

Assisted Solution

by:mbvvsatish
mbvvsatish earned 400 total points
ID: 18062369
its simple.
just extract all the files into a directory using winzip.
then override the extracted files with your .class files that are compiled using 1.4.
and then re-jar the files. its done.
all the resources available in the jar will still be there.
0
 
LVL 9

Author Comment

by:matthew016
ID: 18067096
can't find the jar program ...
I even can't find the jdk directory,
I'm using Websphere ... I can make jar files in WebSphere,
I can try to make a project into WebSphere then export it to JAR ?
0
 
LVL 9

Author Comment

by:matthew016
ID: 18067136
Ok, I made a project into Websphere,
where I copied the sources, but I see that there are compiling errors,
making imports of classes that are not present (not in the jar)
Is this possible ?
0
 
LVL 35

Expert Comment

by:girionis
ID: 18067219
Yes this is. You should import all classes you need from the project properties.
0
 
LVL 9

Author Comment

by:matthew016
ID: 18067321
Those classes will be added into the jar ?
0
 
LVL 9

Author Comment

by:matthew016
ID: 18067343
I ask this because they are not in the original jar (compiled with 1.5)
0
 
LVL 35

Expert Comment

by:girionis
ID: 18067353
It depends. If they are classes that are in your project then yes, they will be added in the jar. But from what you said I can tell that these classes are not in your project (otherwise you would be able to compile them without the need to import them). If you need to include these classes into your jar you would manually have to create the jar file.
0
 
LVL 9

Author Comment

by:matthew016
ID: 18068334
ok , thanks all , it works, I have an  issue in the Manifest File,
but u did enough now, I'll post maybe a question very soon,
stay tuned.
0
 
LVL 35

Expert Comment

by:girionis
ID: 18068389
:)
0

Featured Post

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!

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month16 days, 22 hours left to enroll

864 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