4

I am using getdown to create a means to update a java application. When I have completed this tutorial, I tested if it works on command line as below:

% java -jar c:/downloads/getdown-X.Y.jar c:/netBeans/getdown/src

Thankfully, this works and launches the application. Great.

How do I make a jar file and distribute this?

I tried to make a jar file on this project but it didn't work, this project does not run. When I run this getdown-X.Y.jar on command line.

I think it still using the same file which I created before c:/netBeans/getdown/src. Eventually, it is failing to execute since it is missing the jar file. So, how to make this project into a jar file and distribute it.

Dwayne Patel
  • 315
  • 2
  • 13

1 Answers1

0

I am not sure what OS you are working on.You can do this by creating an executable jar file. Please follow the steps here:

If you want to create a jar file with additional file. Here in below, if you want to create a jar file of imagine src.class with additonal text file with it which is readme.txt

c:\patel\projects\netbeans\getdown\src.class
c:\patel\projects\readme.txt

Run this command: jar -cvfm src.jar readme.txt netbeans\getdown\*.class

which is: c:\patel\projects\jar -cvfm src.jar readme.txt netbeans\getdown\*.class Now your executable jar file is ready. To run this jar file:

run this on command prompt: java -jar src.jar

Community
  • 1
  • 1
  • 1
    this is the part of the tutorial i am working with: Testing To test that your application is working. You can do the following. First download the getdown-X.Y.jar client jar file from Maven Central. Now create a "stub" installation directory that looks like the following (copy getdown-X.Y.jar to getdown.jar): myapp/getdown.jar myapp/getdown.txt Put the contents of the getdown.txt file in your stub directory need contain only a single line: – Dwayne Patel Sep 02 '15 at 14:53
  • 1
    appbase = http://myapplication.com/myapp/ Eventually, you will create per-platform installers that create this stub directory and set up application launchers that are appropriate to the platform in question (or you'll launch Getdown as an applet). But for now, we can run Getdown manually from the command line. With the above directory structure set up, run the following command: % java -jar myapp/getdown-X.Y.jar myapp This will run Getdown, and cause it to download and validate your application and then execute it. – Dwayne Patel Sep 02 '15 at 14:55
  • Add a newline to end of the file. Please refer here 1. http://stackoverflow.com/questions/773610/add-a-new-line-to-a-text-file-in-ms-dos 2. http://stackoverflow.com/questions/7396680/add-new-line-in-text-file-with-batch-file Did you create an executable jar file before you run it? –  Sep 02 '15 at 15:09
  • no i didnt. i created a new project and copied in the getdown.jar and the getdown.txt file into the default package. i did not build the project i just opened up the cmd window and used java -jar c:/downloads/getdown-X.Y.jar c:/netBeans/getdown/src to run. – Dwayne Patel Sep 02 '15 at 16:42
  • Good to hear that, if it all worked right for you. Let me know of any issues. Thanks –  Sep 02 '15 at 16:45
  • i can run the application that way using the cmd line and on my machine but i want to distribute. i am not clear on how getdown run the application – Dwayne Patel Sep 02 '15 at 20:36
  • Great. To distribute or package the executable jar file see this [Link1](http://stackoverflow.com/questions/17176900/how-to-package-executable-jar-file-into-exe ) [Link2](http://introcs.cs.princeton.edu/java/85application/jar/jar.html) –  Sep 02 '15 at 20:44
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/88632/discussion-between-shiva-shinde-and-dwayne-patel). –  Sep 02 '15 at 21:12