Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 525
  • Last Modified:

execute a application such as quicktime from a qt file like double click movie.mov and it run QT

I have written a small app which creates a qlk file and when I double click on this in the normal manor in the OS it opens QT and everything is executed.  But I need to execute this from within java application this file is like a text file not executable any ideas this has to work for mac os 10 and windows.

thank you please
0
jemerton
Asked:
jemerton
  • 17
  • 16
  • 4
  • +1
1 Solution
 
CEHJCommented:
Well I don't know the application, but presumably if you pass the qlk file as a parameter to the program that executes these files, you should be OK. Which program *does* execute them?
0
 
jimmackCommented:
This is not so much of a "problem" as a "feature".  The action to be taken when double clicking is to do with the way you have the "file associations" set up (eg. in Windows Explorer).

If you *really* want to change this, you'll need to edit the file associations.  You should find this under the options somewhere (sorry, I've only used Linux for the last 12 months and my memory of menus on Windows is a bit rusty ;-))
0
 
CEHJCommented:
Let the program (for the sake of argument be called 'Q.exe'):

Runtime.getRuntime().exec("Q.exe c:\somedir\x.qlk");

Adjust the first parameter for the MAC os
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
lwinkenbCommented:
To follow up on CEHJ's comment, you would run:
Runtime.getRuntime().exec("c:\\path\\quicktime.exe c:\\path\\myfile.mov");
0
 
jimmackCommented:
Ah.  I see.  I misunderstood the question.  I think ;-)
0
 
CEHJCommented:
Sorry, I meant to say:

Runtime.getRuntime().exec("Q.exe c:/somedir/x.qlk");
0
 
jemertonAuthor Commented:
The file I am trying to Execute belongs to the Quicktime application so the normal way is double click on something.qlk and quicktime runs and does what evers contained within something.qlk.



0
 
jimmackCommented:
Come on boys.  Windows and MacOS have been mentioned.  Where's the reference to File.separator ;-)
0
 
CEHJCommented:
Let's get it working in Windoze first ;-)

Right-click the qlk file and see what application is set up to execute it
0
 
jemertonAuthor Commented:
import java.io.*;
   import java.lang.*;
    public class CreateFile
   {

   
       public static void main ( String args[])
      {
         Runtime run = Runtime.getRuntime().exec("/Applications/QuickTime Player.app /Users/jason/qt.qtl");
       
         try
         {
   
         

         
            Process exe = run.exec();
         
         
         
         
         }
             catch(Exception e){System.out.println(e);}
      }
   
   }
0
 
jemertonAuthor Commented:
quicktime is set
0
 
CEHJCommented:
>>Runtime run = Runtime.getRuntime().exec("/Applications/QuickTime Player.app /Users/jason/qt.qtl");

Just

Runtime.getRuntime().exec("/Applications/QuickTime Player.app /Users/jason/qt.qtl");
0
 
CEHJCommented:
.app - is that a mac executable? - it sure as hell isn't a Windows one ;-)
0
 
jemertonAuthor Commented:
their is a problem with the space between QuickTime Player.app i get this error

java.io.IOException: /Applications/QuickTime: not found
0
 
CEHJCommented:
Yes - i was afraid that might happen. Try

Runtime.getRuntime().exec("\"/Applications/QuickTime Player.app\" /Users/jason/qt.qtl");
0
 
jemertonAuthor Commented:
same error I just changed the name of the exe QT take space away now I get

cannot execute
0
 
CEHJCommented:
See if you can execute the following at the command line:

"/Applications/QuickTime Player.app" /Users/jason/qt.qtl

If you can't it won't work in Java either
0
 
jemertonAuthor Commented:
[jasons-Computer:/Applications] jason% /Applications/QuickTime Player.app" /Users/jason/qt.qtl
Unmatched ".

0
 
CEHJCommented:
You missed the first quote
0
 
jemertonAuthor Commented:
[jasons-Computer:/Applications] jason% "/Applications/QuickTime Player.app" /Users/jason/qt.qtl
/Applications/QuickTime Player.app: Permission denied.
0
 
CEHJCommented:
Please post the output of

ls -l "/Applications/QuickTime Player.app"

and

ls -l /Users/jason/qt.qtl
0
 
jemertonAuthor Commented:
drwxrwxr-x   3 root   admin   102 May 19 23:48 QuickTime Player.app

0
 
jemertonAuthor Commented:
-rw-r--r--  1 jason  staff  188 Nov 10 23:41 /Users/jason/qt.qtl
0
 
CEHJCommented:
QuickTime Player.app is a directory, not a program
0
 
jemertonAuthor Commented:
so where is the program??? that is a quicktime icon which runs when double click it
0
 
CEHJCommented:
I would also take a guess that that qlt file is not a quicktime file either, but the extension for a Mac quick launch shortcut
0
 
jemertonAuthor Commented:
do you know any other way to execute a file I was thinking about using robot class and lets say the file is on the desktop I highlight the icon and then send the command o to open.

But what if there are windows open and cant access desktop and another thing I would have to lock the keyboard and mouse input on the clients machine while I did the above.

or I could leave the file for the user to open but this is not very interactive that means you have to tell the user there is a file now on their desktop and they find it and open it.



0
 
CEHJCommented:
That's the only really practicable way to execute it. Tell me what the following prints at the command line:

ls -l $( find / -name quicktime)
0
 
jemertonAuthor Commented:
Illegal variable name.
0
 
CEHJCommented:
OK, just do

 find / -name quicktime
0
 
jemertonAuthor Commented:
no find command but I dont know what you mean becuase os says its an application not a dir.  Limewire application can open itunes and I think thats written in java
0
 
CEHJCommented:
It's a directory. I just create a directory with the same name. This is the listing i got:

drwxr-xr-x    2 protean  protean      4096 Nov 15 21:26 QuickTime Player.app

You need to find the executable. Try just

quicktime

If it starts, tell me what the output of this is:

echo $PATH
0
 
jemertonAuthor Commented:
/bin:/sbin:/usr/bin:/usr/sbin

no quicktime did not work
0
 
jemertonAuthor Commented:
got it working thanks for you help.
0
 
CEHJCommented:
Thanks. Please say how!? Don't forget that others have to use this site to get answers.
0
 
jemertonAuthor Commented:
Runtime.getRuntime().exec("open "+System.getProperty("file.separator")+"/filename");

this works on mac would this work for windows as well could you test just enter any file and see if it opens up the related application.

what is the best way in java to detect what OS the java application is running on such as mac or win.

thanks
0
 
jimmackCommented:
You can use File.separator instead fo the System.getProperty() if you want.

This will only work on different platforms if the "open" executable is the same on all platforms.

The system properties os.arch, os.name and os.version can be used to find out which OS you are using.
0
 
CEHJCommented:
File.separator is probably going to be adequate. On Windows, if >= Windows NT, replace 'open' with 'start'
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 17
  • 16
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now