3 Replies Latest reply on Nov 24, 2009 6:22 AM by Loic.Aigon

    launch a jar executable

    nicola.pulvirenti

      Hi all,

       

      I'm developing a javascript for ID CS3 (5.0.4) and I need to launch a java executable (.jar) as if it was double-clicked.

      I do this on OSX platforms and it works fine:

       

      var oJavaApp = new File("/path/to/myjava/folder/myJar.jar");
      var result=oJavaApp.execute();

       

      ...and I tried with a batch file:

       

      var oMyBat = new File("/path/to/myjava/folder/launchMyJar.bat");
      var result=oMyBat.execute();

       

      but no way to make it work on Windows XP

      ...Yes, I even used the win path c:\\path\\to\\myjava\\folder\\myJar.jar

       

      When I double-click either on myJar.jar or on launchMyJar.bat all works fine.

       

      Is there a way to launch that jar from an ID script?

       

      Thanks in advance.

       

      Nicola.

        • 1. Re: launch a jar executable
          Loic.Aigon Adobe Community Professional

          I can't tell you if it's related to XP environment but what I can say is that your windows path doesn't look good:

           

          You may use :

          "C:/xxx/yyyy/zzz" or "/c/xxx/yyyy/zzz" but I don't think "C:\\xxx\yyy\zzz" is correct.

           

          Try this and let us know.

           

          Regards,

           

          Loic

          • 2. Re: launch a jar executable
            nicola.pulvirenti Level 1

            SOLVED!!!

             

            Thanks Loic for your answer.

            Anyway, it wasn't a path problem (even the Windows-style path works).

             

            I discovered that vbs does launch jar files and js doesn't.

             

            So I created a vbs script (let's say javaLauncher.vbs):

             

            Dim oShell, oCurDir
            Set oShell = CreateObject("Wscript.shell")

             

            strPath = Wscript.ScriptFullName
            Set oCurDir = CreateObject("Scripting.FileSystemObject")

             

            Set objFile = oCurDir.GetFile(strPath)
            strFolder = oCurDir.GetParentFolderName(objFile)

             

            oShell.CurrentDirectory = strFolder
            oShell.Run "myJar.jar"
            Set oShell = Nothing

             

            and I call it from inside my javascript:

            oJavaApp = new File("c:\path\to\myfolder\javaLauncher.vbs");

            oJavaApp.execute();

             

            ...and that works!

            • 3. Re: launch a jar executable
              Loic.Aigon Adobe Community Professional

              Nice ;-)

               

              May you have a look on a script I wrote that allow you to write and test code (whatever JS, VB or Applescript) inside of Indesign ?

               

              http://bit.ly/1iDPKJ