Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: update .jar file?

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default update .jar file?

    Hi new to the forum

    quick question for you guru's.

    I have an old .jar file which works on jre 1.2.2 however will not work on anything after that version.

    Poking around i read that javac will be able to compile my old jar file and give me the ability to run it on java 6 or java 7.

    Reading through the man pages i cannot seem to figure out what the command structure is to recompile my jar file. is it even possible?

    reason is i'm on a linux box and trying to get jre 1.2.2 to work properly has been a nightmare so thought i'd try this avenue to see if recompling it would be easier

    thank you


  2. #2
    Forum VIP
    Join Date
    Oct 2010
    Posts
    275
    My Mood
    Cool
    Thanks
    32
    Thanked 54 Times in 47 Posts
    Blog Entries
    2

    Default Re: update .jar file?

    Wow, 1.2 is a very old update! However you should be able to recompile with minimal changing of code. Albeit requiring the source code. Is the question on how to compile or how to jar?

    For information on how to make a jar file, look here:

  3. The Following User Says Thank You to Tjstretch For This Useful Post:

    denti (June 28th, 2012)

  4. #3
    Junior Member
    Join Date
    Jun 2012
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: update .jar file?

    Tjstretch, thank you for the reply

    I'm not sure.. i'm java stupid. all i know is that i have this jar file and would like to run it under a newer release rather than trying to get jre1.2.2 installed and load.

    Looking at the tutorial link, it looks like that's making a jar file. would i have to unpack my jar file, update it and then repackage it?
    I'm really hoping not and there's a simple javac command that will do all that for me
    I'm not a programmer so all this is way over my head

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: update .jar file?

    what the command structure is to recompile my jar file
    The normal jar file does not contain the source files used to create the class files that are executed.
    You will need to find all the .java files for the .class files contained in the jar file. Compiling the .java files will create .class files that you will put into the new jar file with all the other resources from the old jar file. You can use a zip file utility to open a jar file and extract all its contents.
    If you don't understand my answer, don't ignore it, ask a question.

  6. The Following User Says Thank You to Norm For This Useful Post:

    denti (June 28th, 2012)

  7. #5
    Junior Member
    Join Date
    Jun 2012
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: update .jar file?

    Quote Originally Posted by Norm View Post
    The normal jar file does not contain the source files used to create the class files that are executed.
    You will need to find all the .java files for the .class files contained in the jar file. Compiling the .java files will create .class files that you will put into the new jar file with all the other resources from the old jar file. You can use a zip file utility to open a jar file and extract all its contents.
    Norm,
    so it's as simple as unpacking the jar file. grab all my *.java files and then recompile all those .java files so i get .class files then package it all up as a nice jar file again?

  8. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: update .jar file?

    Probably not. I don't know why the program in your old jar file does not execute. I suspect it could be because of something that has been removed from the current version of java. If that is the case you will need a java programmer to rewrite the code to use current classes and methods to replace the old versions.

    You should try executing the jar file manually and copying the error messages here so we can evaluate the problem. I don't know linux so this might not be the right way. Open a command prompt/terminal window, change to the folder with the jar file and enter this command:
    java -jar <THEFILENAMEHERE>.jar
    Copy the terminal window's contents and paste here
    If you don't understand my answer, don't ignore it, ask a question.

  9. #7
    Junior Member
    Join Date
    Jun 2012
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: update .jar file?

    norm, thank you for your help but looking into abit further, i don't beleive what i'm trying to do will work.

    the jar file i have connects to another device and from there it runs. after it starts, it does a software compatibility check and then it fails. I suspect it's calling .java files or other executables from the device it's connected to. as the java version are different it'd being handled differently and then stops working.

    running the java as
    java -jar file.jar 192.168.10.2 so it's safe to assume all the "guts" or important stuff is on the device

    want to thank everyone that's helped

  10. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: update .jar file?

    Hard to say what is happening without seeing the full text of the error messages.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Paramaters to update properties file
    By d0nal in forum Java Theory & Questions
    Replies: 1
    Last Post: September 14th, 2011, 11:17 AM
  2. Why my update.jsp is not working?
    By tangara in forum JavaServer Pages: JSP & JSTL
    Replies: 4
    Last Post: September 8th, 2011, 01:14 AM
  3. Want to Update Class File content
    By AlokPatil in forum Member Introductions
    Replies: 1
    Last Post: August 26th, 2011, 11:45 PM
  4. Cannot update data in .txt/.csv file
    By Azriq007 in forum JDBC & Databases
    Replies: 2
    Last Post: October 16th, 2010, 09:16 PM