Solved

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

Posted on 2003-11-15
38
510 Views
Last Modified: 2009-07-29
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
Comment
Question by:jemerton
  • 17
  • 16
  • 4
  • +1
38 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 9755197
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
 
LVL 15

Expert Comment

by:jimmack
ID: 9755200
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 9755216
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
 
LVL 5

Expert Comment

by:lwinkenb
ID: 9755217
To follow up on CEHJ's comment, you would run:
Runtime.getRuntime().exec("c:\\path\\quicktime.exe c:\\path\\myfile.mov");
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9755224
Ah.  I see.  I misunderstood the question.  I think ;-)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9755228
Sorry, I meant to say:

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

Author Comment

by:jemerton
ID: 9755237
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
 
LVL 15

Expert Comment

by:jimmack
ID: 9755239
Come on boys.  Windows and MacOS have been mentioned.  Where's the reference to File.separator ;-)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9755241
Let's get it working in Windoze first ;-)

Right-click the qlk file and see what application is set up to execute it
0
 

Author Comment

by:jemerton
ID: 9755257
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
 

Author Comment

by:jemerton
ID: 9755263
quicktime is set
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 9755266
>>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
 
LVL 86

Expert Comment

by:CEHJ
ID: 9755270
.app - is that a mac executable? - it sure as hell isn't a Windows one ;-)
0
 

Author Comment

by:jemerton
ID: 9755280
their is a problem with the space between QuickTime Player.app i get this error

java.io.IOException: /Applications/QuickTime: not found
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9755291
Yes - i was afraid that might happen. Try

Runtime.getRuntime().exec("\"/Applications/QuickTime Player.app\" /Users/jason/qt.qtl");
0
 

Author Comment

by:jemerton
ID: 9755324
same error I just changed the name of the exe QT take space away now I get

cannot execute
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9755334
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
 

Author Comment

by:jemerton
ID: 9755350
[jasons-Computer:/Applications] jason% /Applications/QuickTime Player.app" /Users/jason/qt.qtl
Unmatched ".

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9755354
You missed the first quote
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:jemerton
ID: 9755383
[jasons-Computer:/Applications] jason% "/Applications/QuickTime Player.app" /Users/jason/qt.qtl
/Applications/QuickTime Player.app: Permission denied.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9755404
Please post the output of

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

and

ls -l /Users/jason/qt.qtl
0
 

Author Comment

by:jemerton
ID: 9755405
drwxrwxr-x   3 root   admin   102 May 19 23:48 QuickTime Player.app

0
 

Author Comment

by:jemerton
ID: 9755421
-rw-r--r--  1 jason  staff  188 Nov 10 23:41 /Users/jason/qt.qtl
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9755430
QuickTime Player.app is a directory, not a program
0
 

Author Comment

by:jemerton
ID: 9755448
so where is the program??? that is a quicktime icon which runs when double click it
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9755533
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
 

Author Comment

by:jemerton
ID: 9755537
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 9755584
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
 

Author Comment

by:jemerton
ID: 9755608
Illegal variable name.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9755658
OK, just do

 find / -name quicktime
0
 

Author Comment

by:jemerton
ID: 9755749
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 9755842
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
 

Author Comment

by:jemerton
ID: 9755950
/bin:/sbin:/usr/bin:/usr/sbin

no quicktime did not work
0
 

Author Comment

by:jemerton
ID: 9757130
got it working thanks for you help.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9758171
Thanks. Please say how!? Don't forget that others have to use this site to get answers.
0
 

Author Comment

by:jemerton
ID: 9758683
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
 
LVL 15

Expert Comment

by:jimmack
ID: 9758948
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 9758961
File.separator is probably going to be adequate. On Windows, if >= Windows NT, replace 'open' with 'start'
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bunnyEars2 challenge 6 70
DO we need Java installed on a Windows PC and WHY ? 13 78
eclipse formatting 6 43
maven project error 5 21
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now