Solved

[URGENT] JAR Files

Posted on 2006-12-01
29
211 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
[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
  • 12
  • 8
  • 8
  • +1
29 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 200 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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
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 200 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 100 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

728 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