5 Replies - 1001 Views - Last Post: 26 February 2011 - 01:49 PM Rate Topic: -----

#1 ScottH323   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 03-February 11

Program not running a second program

Posted 26 February 2011 - 10:48 AM

I have been using the tutorial to add a updater into my java program frome here: Updater Tutorial

The problem i am having however is that the initial programme doesnt go on to run the second .jar file or even run the file in netbeans and just shuts down instead.

i believe this bit of code to be the thing that isnt working but i have done a tonne of system out's and it just runs straight through the code without running the second programme:
private void update() {
        String[] run = {"java", "-jar", "updater/update.jar"};
        try {
            Runtime.getRuntime().exec(run);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        System.exit(0);
    }


my folders/files are in this path:
LibTiles.jar   (initial file that runs this code)
updater/update.jar


can anyone see any errors or have i done something wrong in another place?

Is This A Good Question/Topic? 0
  • +

Replies To: Program not running a second program

#2 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Program not running a second program

Posted 26 February 2011 - 12:51 PM

This is a single command

String[] run = {"java", "-jar", "updater/update.jar"};

not 3 different commands. Try

String run = "java -jar updater/update.jar";

This post has been edited by pbl: 26 February 2011 - 01:19 PM
Reason for edit:: {}

Was This Post Helpful? 0
  • +
  • -

#3 ScottH323   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 03-February 11

Re: Program not running a second program

Posted 26 February 2011 - 01:16 PM

just gives me the error :
illegal initializer for java.lang.String

Was This Post Helpful? 0
  • +
  • -

#4 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Program not running a second program

Posted 26 February 2011 - 01:18 PM

did you remmove the [] after your String and mamy no {} my mistake

String run = "java -jar updater/update.jar";
Was This Post Helpful? 0
  • +
  • -

#5 ScottH323   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 03-February 11

Re: Program not running a second program

Posted 26 February 2011 - 01:28 PM

yea it sitll doesnt work. Do i have to try and package the 2 projects (1 being LibTiles.Jar and the other being update.jar) into .jar file because i think i may of read the tutorial incorrectly as he says:

Quote

VERY IMPORTANT: For all this to work when you are ready to package your java program to distribute make sure that you include the folder updater with the update.jar in it for this to properly work!
So the final paths should look like this:
../<my app>.jar
../updater/update.jar


and if this is the case how would i go about creating a jar out of the two other jars as netbeans did the first two for me
Was This Post Helpful? 0
  • +
  • -

#6 ScottH323   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 03-February 11

Re: Program not running a second program

Posted 26 February 2011 - 01:49 PM

Its seemingly fixed itself, i just redid the code exactly the same so not entirely sure what happened but it must be something to do with the paths.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1