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
518 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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!

 
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
 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jmss example java 2 48
Netbeans and org.apache.commons.lang3 issue 3 55
Java List 4 76
Session in java desktop 5 38
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

751 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