Launch external files on Linux

I want to launch external files from Java, in a cross platform way.
ie say I have a file fred.jpg, I want to launch that on any platform to open in the editor defined on that computer.
The book 'Swing Hacks' (Marinaccci and Adamson), shows how to do this for Windows and Mac. My version of their code is
     static public void launch(URL url){
          try{
               String cmd;
               if (OS.isMac())
                    cmd = "open "+url;
               else     // TODO linux?
                    cmd = "cmd.exe /c start "+url;     
               Runtime.getRuntime().exec(cmd);
          catch(Exception e){new Fail(e);}          
     }However, I don't know what to put in for linux?
Searching the web I came across http://weblogs.java.net/blog/ixmal/archive/2006/05/javaawtdesktop.html,
which suggests that
Desktop.getDesktop().open(new File(filename));is more platform independant. However for me it seems to work only on Windows, failing silently on Mac and Linux?
Can someone with a good knowledge of Linux help please.

>
Will Duke stars get anyone to answer this?>I cannot say. What I can tell you is that at least it got me to read it.
And now I look over your original post..
>
..However for me it seems to work only on Windows, failing silently on Mac and Linux?>'Seems'? The docs. for Desktop.open(File) suggest it throws a whole range of exceptions if it cannot perform the task. Are you sure the code is not 'swallowing exceptions'?
Can you produce an SSCCE that fails as you claim? If so, this really sounds like a bug.
And as an aside, Desktop was introduced in 1.6, but AFAIR, Apple is still stuck on 1.5. How did you get it to 'fail silently' on a Mac.?
Edit 1:
But if you are intent on doing it the way that you originally asked about, you might be able to pick up some tips from the [http://browserlaunch2.sourceforge.net/|BrowserLauncher2] code.
Edited by: AndrewThompson64 on May 22, 2008 4:48 PM

Similar Messages

  • Launch external files from a presentation

    preparing a long presentation with many external files (of many kinds: swf, quicktime, html, etc) as examples.
    I am trying NOT to stop the keynote, go thru the finder launching different files in front of the audience.
    I would much prefer if i can use a button inside my presentation to launch that specific file.
    Any ideas? 3rd party plug ins? automator script?

    Keynote has no scripting capabilities what so ever :/.
    Obviously some of the file types you describe can be placed into the Keynote presentation itself. QT, Insert Menu> Webview for web page inside presentation; with textbox selected... Insert menu >Text Hyperlink > Webpage to change to browser and link to url. Email message?! Not files as such though.
    I'm sure you could write an applescript to run in parallel to the presentation to handle all the file launching in a sequence for you or even with a list of buttons if you wanted to get really serious with UI builder.
    Flash support was dropped as a consequence of changes to QT. Flash support inside QT was discontinued (security?).

  • Launch External Files from SSRS

    I have a report that will list the names of files that are attached to this report in the database.  I would like to include the list of files from the database and allow the users to click or double click the file name and have the file load. 
    Is there a way for SSRS to do this?  The files can be in multiple formats, and in the project that adds the files we can use:
    System.Diagnostics.Process.Start(filepath)
    And it will launch the correct process to view the files.  I have stored the the file itself in an image column, and I also have the full path and the file name in columns as well so I could create a dataset to retrieve the file names and show them
    on the report.
    Anyone have any suggestions?
    Thanks.

    Hi katghoti,
    If I understand correctly, you want to embed external files (word, pdf, image etc.) into a report in Reporting Services. If in this scenario, I suggest that you can use the following two methods to achieve your requirement:
    Embed these files into database.
        1) Use the SQL commands to embed these files in database as the image data.
        2) Use the .net language (C#, VB) to convert this data into the image.
        3) Use the image control to show these images, which are files embedded in database.
    Reference:
    How to embed a pdf document in Reporting Services
    Upload these files in the report server, access them using URL.
        1) We can upload these files in the report manager.
        2) Adding hyperlinks to reports to link to these files stored on the report server.
    Reference:
    URL Access Parameter Reference in Reporting Services
    How to add a Hyperlink to a URL in Reporting Services
    Hope this helps.
    Thanks,
    Katherine Xiong
    If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support

  • Launching an external file

    Hello.
    I have a DOCUMENTS table with a reference to external documents files.
    The 'FILE_NAME' (varchar2) field is the place for the complete path and name, for example...
    'd:\works\archived\Contract-2002-05-21.doc'
    I made a page with a SQL query in a Form Region that displays the documents table content, and I want add a link in the doc_id column that launch the file opening its associated application.
    I tried to use #DOC_ID# as text link and the FILE_NAME as URL destination
    without success

    mburgos,
    Take a look at this doc for starters:
    http://download-east.oracle.com/docs/cd/B31036_01/doc/appdev.22/b28839/up_dn_files.htm
    Unless the end users have mapped drives to those documents, that's not going to work. Is this path just a pointer to the file on the server (if so, why not a BFILE)?
    chet

  • Launching external viewer per file type

    From my Java program I need to launch external viewers per file type. Is there any easy way to do this?
    My program may generate various output files (eg. html, txt, pdf ...etc). Once a file is generated, I want to launch corresponding registered viewer on users desktop so user can view the output(eg. for "HTML" registered web browser OR for TXT launch Notepad OR for PDF launch Acrobat etc).
    I suspect that this functionality may become OS-dependent but maybe somebody knows a "pure java" way of doing this?
    Even if I could do it for Windows only that'd be get me by for the moment. If somebody knows a Window's specific solution even that would help.
    TIA.

    Actually after some more searching I stumbled upon this at javaworld.
    On Windows one can execute url.dll that interpretes the given file (or URL) argument and launches appropriate viewer.
    For example to launch HTML viewer you execute the following command using runtime..
    rundll32 url.dll,FileProtocolHandler http://www.javaworld.comTo launch notepad you use the following command.
    rundll32 url.dll,FileProtocolHandler C:\myfile.txtThought it might be useful for anybody else reading this thread...

  • Launch an external file using Java

    I have an app that creates an .rtf file, I want to be able to open it up once it's created. How do I launch the file from within the app if I have the filepath?

    I tried the following with an .rtf file in the same directory,
    import java.io.*;
    public class Test {
       public static void main(String[] args) {
          Runtime run = Runtime.getRuntime();
          try {
             run.exec("temp.rtf");
          } catch (Exception e) {
             e.printStackTrace();
    }But I get a message telling me that temp.rtf is not a valid Win32 application. I don't want to specify which program the file opens with, I'd like it to launch with the os default as if I double-clicked the file.
    edit: is there a way I can get the exe that the system has associated with the rtf extension?

  • Reader 9.3.3 (Vista) : problem to launch external application

    Hello!
    I have a file which have links to start external application.
    In Adobe Reader 9.3.3 (Windows Vista), I have that dialog box (in french, sorry) :
    How can I activate launching external applications?
    Thank you for your help.
    François

    This is a security issue. Try looking at the Preferences under the Trust Manager.

  • How to convert the MS access *.mdb files to Linux oracle?

    Dear all,
    I got a MS Access *.mdb file which has several tables inside
    it. We will like to convert this file into our new oracle
    database of Linux. How should I do to accomplish the converting
    task?
    null

    A third way to convert Access to Oracle is to setup ODBC on the
    client PC which has the access databases.
    Start Access and open the database to the Table view.
    For each table:
    Chose File -> Save As/Export... -> External File or DB -> ODBC
    Enter the table name for the table in Oracle (case used to be a
    problem -- you may have to try uppercase or lowercase)
    Choose the Oracle ODBC driver and login to the Oracle DB.
    Should show you a progress bar while the data goes in.
    You can get the client side Oracle stuff by downloading a trial
    NT server or some other trail software. ODBC drivers are free.
    As I understand it, the Access migration assistant will bring
    across more than just the tables.
    You should probably bring across the data into some temporary
    tables first, then create your real tables and copy across the
    data. That way you can fix things that were broken in the Access
    version.
    Cheers,
    Colin
    null

  • Storing data out to external file...?

    I have a question I'd like to put forward to anyone who can
    help me. It's a bit vague, perhaps, but any help would be
    appreciated...
    I need to make a Flash application into which you can INPUT
    data, and then have that data STORED somehow / kept in memory -
    probably in an external file of some format outside of the Flash
    file, so that the next time you launch the Flash file, that same
    EXTERNAL data will be read by the Flash file and will display in
    the interface.
    The key thing here though is that file will NOT be hosted
    online, so it cannot make use of any "online-only" scripting (if
    such a thing exists?).
    I need to host and run the Flash application from my local
    hard drive, and all external files need to be on my local hard
    drive too.
    Is it possible to set up the scenario I've outlined? Where do
    I even begin?
    I fully appreciate that this will be a big project, requiring
    a great deal of learning on my part, but I'm willing to give it a
    go, providing I know where to start...
    What am I looking at here? PHP? CGI? XML? Will those run
    locally? I really don't know...
    Like I said, I really know nothing about any of this, and I'm
    perfectly willing to learn, but I just need to know WHERE to start
    learning, and WHAT to learn...
    Again - any help appreciated.
    Thanks.

    you can use the flash sharedobject to store data from one
    flash session to another.

  • Open external files

    I`ve been doing some research for a while, but haven`t found any solution for opening external files in my java app.
    Short about my problem:
    I`m giving users of the program the opportuninty to upload different kind of files. When a file is uploaded a label with the filename appears in the screen. When they click on the label I want my program to launch the correct program... Acrobat Reader for .PDF, Paint for jpg,gif.... aso.
    I found something similar that launch the cmd.exe, but it isn`t a general solution that opens all kinds of files...
    http://forum.java.sun.com/thread.jspa?threadID=625707&messageID=3569795
    As mentioned above I haven`t, so far, found a reliable solution for the problem, and I would have apprecated any kind of help.
    YS.
    Kaare

    Pre 1.6:
    JDIC
    org.jdesktop.jdic.desktop.Desktop.open(java.io.File)
    Java 6
    java.awt.Desktop.open(java.io.File)

  • Got ORA error when trying to execute external file using scheduler

    Hi All,
    I have executed the below program. In the log i have seen the error like below
    BEGIN
    dbms_scheduler.create_job('"TEST_JOB_EXE2"',
    job_type=>'EXECUTABLE', job_action=>
    '/home/upncommon/pub/test123'
    , number_of_arguments=>0,
    start_date=>TO_TIMESTAMP_TZ('23-AUG-2013 05.35.27.557242000 AM -04:00','DD-MON-RRRR HH.MI.SSXFF AM TZR','NLS_DATE_LANGUAGE=english'), repeat_interval=>
    'freq = minutely;'
    , end_date=>TO_TIMESTAMP_TZ('24-AUG-2013 05.35.27.000000000 AM ASIA/CALCUTTA','DD-MON-RRRR HH.MI.SSXFF AM TZR','NLS_DATE_LANGUAGE=english'),
    job_class=>'"DEFAULT_JOB_CLASS"', enabled=>FALSE, auto_drop=>FALSE,comments=>
    'Job to test use of dbms_scheduler'
    dbms_scheduler.set_attribute('"TEST_JOB_EXE2"','credential_name',
    '"EXECUTABLE"');
    dbms_scheduler.enable('"TEST_JOB_EXE2"');
    COMMIT;
    END;
    "EXTERNAL_LOG_ID="job_196709_23673",
    ORA-27369: job of type EXECUTABLE failed with exit code: Input/output error
    STANDARD_ERROR="Launching external job failed: Login executable not setuid-root""

    my version details are:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    "CORE 11.2.0.3.0 Production"
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production

  • Opening external files

    Hello, im starting in flash, and i want to open external
    files with buttons, for a cd menu that i'm creating. I have created
    an fscommand folder and a launcher.bat that execute the file that i
    want when i press the button. But what i really want is to execut a
    file whatever it name is. For example i want to execute a .pdf file
    whitout calling it by the name to give me the chance to use de cd
    menu with various cds. Can anyoune help me with the code to the
    launcher.bat file? I have tryed start *.pdf but it didn't work.
    Thank you.

    does it have to be through a url, can't it be trough a path,
    like C:\file.rar or something like that? it's because the computer
    where i'm going to do the presentation does not have internet, so
    that way won't help me much

  • Opening External Files using SWF

    Hi all,
    Is there a way to open external files using swf? I have gone
    through a number of forums and all seem to tell me to open with a
    window projector. my problem is, I need to embed the swf into a
    html to be viewed online... So I need to do it in swf format.
    Any ideas?

    When you say 'external files' I presume you mean local files
    on the users hard drive.
    If that's true:
    When you say 'open' what do you mean? It could mean to open
    and load a text file/xml file or another swf in flash or it could
    mean to launch a document in its native application e.g. .doc
    launches word etc. Flash projectors can do the first thing, but not
    the second thing. And you need to know the path of the file because
    I don't believe you can retreive it from the filereference browsing
    support. 3rd party tools are necessary to really add a lot of file
    system support to projector applications, and then you can do both
    things mentioned here, without the limitations of flash player
    security which is only slightly reduced with regular projector
    files.
    The filereference class in flash is primarily for
    upload/download support. You can't 'open' local files with it.
    There is, to my current knowledge, no way you can do that with
    flash in a html page directly.
    The only way I can think that it might be possible (untested)
    would be to have a separate local MS Office (or any other host for
    a flash activex that gives filesystem access) with some embedded
    flash in a document that (perhaps) could talk via local connection
    with your html page content and which would in turn talk to its VBA
    host to request local file system activity. I don't know if this
    would work because I've not used localconnection, but perhaps it
    might.

  • Launching External programs from an addon cause Client to stop

    Hi.
    We have an add-on that allow via configuration to launch other programs/files from SAP (Remote desktop, PDF-documents, etc.).
    Launching other processes from an add-on is easy with the System.Diagnostics.Process.Start(file, arguments);
    This has worked since SBO2004A, but since we began working with SBO2005A SP01 launching external programs cause the SAP Client to freeze every 5-10th time or so...
    Nothing except stopping the add-on-process works.
    When the add-on is terminated the Client "Wakes up" to inform that add-on has been disconnected.
    Anyone else have had a similar problem?
    <i>Kind Regards
    Rasmus Wulff Jensen | http://www.b1up.net</i>

    Regarding the thread, I whought about it, but since it is a process.Start, it a whole different process and threads should not have anything to do with it...
    As always, yes I've created a message for this.... And got the normal response from SAP Support "We cant reproduce the issue... please send sample code"... sigh.... Hate random error that can't be reproduced... and sample code is hard to produce when you have created a whole framework above the SDK... I almost never do any "Core" SDK...

  • Opening external files in Director Projector... *URGENT*

    Hi, this should be really basic, but I just can't work it
    out...
    I want to open external files (but kept in the same root
    directory as my projector file) from a mouse/button click in my
    projector.
    I don't know any Lingo, but I am assuming it should be pretty
    straight forward... I need to launch a .pdf, a .html file (I can do
    this with the goto URL behaviour actually), and a .exe.
    Is there not a preset behaviour for this somewhere?
    Your help is much appreciated.

    > Are we sure that I am doing this right?
    What about the following - copy it into your cast as a
    behavior and
    attach it to all your buttons, one at a time, choosing the
    file you want
    to open when you click each button. You might need to remove
    previous
    code attempts from your buttons. Be sure to include FileXtra4
    with your
    projector - (Menu:) Modify -> Movie -> Xtras..., click
    Add, locate the
    xtra and add it to the list displayed; or simply place it in
    a folder
    named 'Xtras' alongside your projector
    property myFile
    on getPropertyDescriptionList
    fx4 = xtra("FileXtra4").new()
    tRange = fx4.fx_FolderToList( _movie.path )
    fx4 = VOID
    return [#myFile: [#comment: "File to open:", #format:
    #string,
    #default: tRange[1], #range: tRange]]
    end
    on mouseUp me
    tDelimiter = the itemDelimiter
    the itemDelimiter = "."
    tType = the last item of myFile
    the itemDelimiter = tDelimiter
    fx4 = xtra("FileXtra4").new()
    if tType = "exe" then
    OK = fx4.fx_FileRunApp( _movie.path & myFile )
    else
    OK = fx4.fx_FileOpenDocument( _movie.path & myFile )
    end if
    if ( OK <> 1 ) then
    alert "Error opening file:" && myFile
    &RETURN& fx4.fx_ErrorString()
    end if
    fx4 = VOID
    end

Maybe you are looking for