[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

[URGENT] JAR Files

Posted on 2006-12-01
29
Medium Priority
?
215 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 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

656 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