This discussion is archived
9 Replies Latest reply: Jul 26, 2010 6:21 AM by EJP RSS

Please help me on Jar files

843804 Newbie
Currently Being Moderated
Hi Friends,

I need on eurgent help on jar file,i need to make java application as an exe file.It is standalone swing application ,I want to make it as one double clickable exe file or i want to make it as jar file (it should execute when double c;licked.)If i can make a single jar file,there are some tools to make it as exe file.Now i can make my applicationa as sinlgle jar file which executes finely.But the problem i m facing is that, resource part.I have a properties file in the root folder.I want to read and write to the properties file.I can make it if it is at the root folder.But if it is inside the jar ,how can i write properteis file.I am able to read the properties fileinside the jar file using some Classlaoder,but i m not able to write the properties files inside the jar files.Please anybody can help me on this,/urgent please...I have read that somewhhere like jar file is read only so we cant write .Is there any way to do this ..hope someone helps..

thanks in advance
sumana
  • 1. Re: Please help me on Jar files
    EJP Guru
    Currently Being Moderated
    You want to read and write properties that are in the JAR file and you don't want to have a JAR file, you want to have an EXE.

    You'll have to think more clearly than that.
  • 2. Re: Please help me on Jar files
    793415 Pro
    Currently Being Moderated
    ..I need on eurgent help on jar file..
    <DWS>
    I have considerable experience on the problems of distributing applications that have properties files that might be updated, as well as the efficacy of making .exe files.

    But when I read your post again more carefully, I noticed the bit about it being urgent, and realized I was already too late. :(

    In the future, I strongly recommend hiring a consultant for urgent projects. And of course, pay them an hourly rate that reflects your level of urgency.

    Good luck with your project!
    </DWS>
  • 3. Re: Please help me on Jar files
    843804 Newbie
    Currently Being Moderated
    Hi Friend

    I hope forums is for urgent help..Sory if i wrote any mistakes and for my bad english .:(
    Actually i have one application which writes and reads to a properties file.I want to make that application as a single jar or exe file,the thing is that i need only one file which should exceuted by double click .So if i deliver my application as a single jar or exe file ,the user will invoke the applciation by double clicking it.Can anybody help me with the same, and help me with the answer for the question "i have to create jar file or exe file?". I create a single jar file, bt i am not able to write to the properties file.Can anybody help please...

    Thanks in Advance

    Sumana
  • 4. Re: Please help me on Jar files
    EJP Guru
    Currently Being Moderated
    You can't do this. It's impossible. If you want to write to the .properties file you have to put it outside the JAR file. Maybe you can deliver the default properties in the JAR file, and if the user changes it write a user-specific properties file to his user.dir directory. If that file exists, it is an override, otherwise use the defaults in the JAR file.

    My only comment regarding converting a JAR file to a executable is 'don't'. There is nothing to be gained and an enormous amount to be lost.
  • 5. Re: Please help me on Jar files
    843804 Newbie
    Currently Being Moderated
    Hi friend ,so what u mean to say i cant deliver it as a single jar file or exe file including the properties file.So is there any way to deliver it as a single file,or instead of storing the values in properties file,can i store it anywhere in the applciation .I dont know i m just asking,as it is requirement now.My requirement is that the application should be single exe or jar file and nothing can be copied into the user syatem other than the exe file.
    Please suggest me any other best thing ..Hope ur suggestion helps..

    Thanks in Advance

    Sumana
  • 6. Re: Please help me on Jar files
    EJP Guru
    Currently Being Moderated
    Hi friend
    I am not your friend. I am a guy on a forum.
    so what u mean to say i cant deliver it as a single jar file or exe file including the properties file.
    Don't tell me what I mean to say. I know what I mean to say. I already said it. And that's not it. Please read what I actually wrote, not your mangled miscomprehension of it.
    So is there any way to deliver it as a single file
    I've answered that. No.
    or instead of storing the values in properties file,can i store it anywhere in the applciation.
    That's meaningless but I have provided you with a solution. Is there something wrong with it? or possibly something you don't understand about it?
    My requirement is that the application should be single exe or jar file and nothing can be copied into the user syatem other than the exe file.
    Then your requirement will have to be revised. Both JAR files and exe files are read-only.
    Please suggest me any other best thing ..Hope ur suggestion helps.
    My suggestion should already have helped.

    It is extremely tiresome to have provided a complete workable solution and have the recipient behave as though he hasn't even read it.
  • 7. Re: Please help me on Jar files
    843804 Newbie
    Currently Being Moderated
    Hi

    First of all ,thanks a lot for ur valuable information and for finding the time for replying , I have got the same solution that you have mentioned above from other source and also i have read ur solution clearly and meaningfully.I just want to know like is there anybody who have different idea or who somebody has done something like this...Hope not only the one person sees and replys this forum ..So please use this forum for sharing ur valuable information and great ideas and not for getting irritated ....I am sorry for any inconvenience caused by me .
  • 8. Re: Please help me on Jar files
    793415 Pro
    Currently Being Moderated
    I hope forums is for urgent help..
    No, they are not. Searching forums might provide urgent help, or as I mentioned before, hiring a consultant.
    ..Sory if i wrote any mistakes and for my bad english .:(
    I do not mind bad English, but I do mind laziness. Your constant use of 'u' and 'ur' are not things likely to make me want to help you.

    When you want my help, please do your best to [write well|http://catb.org/esr/faqs/smart-questions.html#writewell] *(<- link).*
    --------------
    But back to the technical problem. ejp provided a good solution back in [reply 4|http://forums.sun.com/thread.jspa?messageID=11025978#11025978] *(<- link).*

    The only way I would tweak that solution is to put the properties file in a sub-directory of user.home based on the package name of the main class. That would help avoid name collisions between your app. and any other app. that might want to store (for example) user options.

    I completely agree that it makes no sense to convert a Jar to a .exe.
    --------------
    On the other hand, if you can distribute from a web server and the application has a GUI, there is yet another option - [Java Web Start|http://java.sun.com/javase/technologies/desktop/javawebstart/index.jsp] *(<- link).*

    JWS offers many nice features for the end user, and also provides the PersistenceService to allow the app. to store small amounts of data. Where it stores the data, I neither know nor care, just so long as it available to the app. the next time it runs. Here is a small [demo. of the PersistenceService|http://pscode.org/jws/api.html#ps] *(<- link).*

    I would have provided that information around two days ago, when you first asked, but I was busy helping people who did not think their problem was more urgent than that of other people.
    ---------------------------
    And no, I am not your friend either, just another guy on a forum.
  • 9. Re: Please help me on Jar files
    EJP Guru
    Currently Being Moderated
    The inconvenience is yours. Wasting time when the question has been answered. I'm used to it, I've been on the Internet for about 20 years, and Usenet before that. The point is, what is the point of asking a question if you don't read the answers? But you're not the first and you won't be the last.