1

I have 3 jars: jar1, jar2 and jar3, in the same path who can change in other pc (ex: c:\prova)

When I run jar1, it moves jar2 in the Windows Sturtup folder.

I want that jar2 simply activate jar3 at every windows startup, but of course it doesn't find jar3 who is remained in the first path.

So I want that jar1 pass a reference (in this case the path c:\prova) to the jar2, when moving it, or at least on the first call to it.

I find it difficoult because: I can't write the path in a text file in jar2: text files in jars aren't writable.

I can't write the text file in the windows Startup folder: it will be opened at every win startup..

I can't pass the path as a parameter, it will be good for the first call but I can't store this value for the succesive calls.

Sorry for my bad english, thanks for any help!

T30
  • 11,422
  • 7
  • 53
  • 57
  • jar1 can unzip jar2, add a txt file with the path and than re-jar jar2 in the startup folder.. is this the only way? – T30 Sep 17 '12 at 10:06
  • Why can't you just create a Windows shortcut`.lnk` file in the windows startup folder that points to jar3 and completely get rid of jar2? Or, alternately, add a key to the windows startup registry pointing to jar3? – Matt Razza Sep 17 '12 at 20:59
  • You're agree, but in my case jar2 don't execute jar3 at windows startup, in facts he check the time and execute jar3 every midnight. I don't want to put the time-control in jar3 'cause i want to run it manually sometimes.. – T30 Sep 19 '12 at 15:12

1 Answers1

1

To add the file Path.txt (with jar3's path) in jar2:

Runtime.getRuntime().exec("jar uf jar2.jar Path.txt");

To read the file in jar2 (Startup is my class name):

        String s = "/Path.txt";
        is = Startup.class.getResourceAsStream(s);
        br = new BufferedReader(new InputStreamReader(is));
        while (null != (line = br.readLine())) {
            list.add(line);
        }

Thank me!

Andrei Sfat
  • 8,440
  • 5
  • 49
  • 69
T30
  • 11,422
  • 7
  • 53
  • 57