[URGENT] JAR Files

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.
LVL 9
matthew016Asked:
Who is Participating?
 
girionisConnect With a Mentor Commented:
0
 
matthew016Author Commented:
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
 
girionisCommented:
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
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
girionisCommented:
> 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
 
girionisCommented:
But, as a side not, if you have the source code you should also have the resources as well.
0
 
sciuriwareCommented:
May I presume that those other files are no class files and thus JAVA version independent?

;JOOP!
0
 
matthew016Author Commented:
Ok, so I'll make a JAR of the classes,
how do I put the ressources in it ?
0
 
matthew016Author Commented:
sciuriware >> All classes need to be replaced, the other things are ressources like a Manifest file and a .LIST file.
0
 
sciuriwareConnect With a Mentor Commented:
Use the jar.exe command from the commandline.

type:              jar

for all options.

;JOOP!
0
 
sciuriwareCommented:
That reveals that you could have replaced the .class files in the old jar

;JOOP!
0
 
matthew016Author Commented:
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
 
sciuriwareCommented:
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
 
matthew016Author Commented:
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
 
sciuriwareCommented:
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
 
matthew016Author Commented:
I can also just open it in Winrar ....
0
 
sciuriwareCommented:
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
 
matthew016Author Commented:
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
 
sciuriwareCommented:
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
 
girionisCommented:
> 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
 
sciuriwareCommented:
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
 
mbvvsatishConnect With a Mentor Commented:
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
 
matthew016Author Commented:
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
 
matthew016Author Commented:
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
 
girionisCommented:
Yes this is. You should import all classes you need from the project properties.
0
 
matthew016Author Commented:
Those classes will be added into the jar ?
0
 
matthew016Author Commented:
I ask this because they are not in the original jar (compiled with 1.5)
0
 
girionisCommented:
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
 
matthew016Author Commented:
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
 
girionisCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.