Desktop API

Hi guys,
How can I check whether any given file type is supported, before actually opening it.
The open method opens the file straight away, and in case the file hasn't any associated application it raises an exception, but there is no what that I am aware of that lets me query the os to know if it "undestands" the file.
Thanks,
MeTitus

I looked at the source for the Desktop class before:
    private static void checkFileValidation(File file){
        if (file == null) throw new NullPointerException("File must not be null");
        if (!file.exists()) {
            throw new IllegalArgumentException("The file: "
                                               + file.getPath() + " doesn't exist.");
        file.canRead();
    private void checkActionSupport(Action actionType){
        if (!isSupported(actionType)) {
            throw new UnsupportedOperationException("The " + actionType.name()
                                                    + " action is not supported on the current platform!");
    private void checkAWTPermission(){
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkPermission(new AWTPermission(
                                   "showWindowWithoutWarningBanner"));
    public void open(File file) throws IOException {       
        checkAWTPermission();
        checkExec();
        checkActionSupport(Action.OPEN);
        checkFileValidation(file);
        peer.open(file);
    private void checkExec() throws SecurityException {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkPermission(new FilePermission("<<ALL FILES>>",
                                                  SecurityConstants.FILE_EXECUTE_ACTION));
    }But the method that actually opens the file is provided by the DesktopPeer.open() method which is implemented natively, so I really think that there is not way to get this done the way it was supposed to be, lets just hope they add some more usufull methods to the Desktop class.

Similar Messages

  • Application crashes when trying to open jpg with Desktop API

    Hi, i would like to open jpg, or gif files using Desktop API, and the application crashes.The Desktop API is supported by my OS, because txt files, or file directories can be opened, mails can be sent, browsing is also supported.
    Only jpg and gif, and i think other picture formats cannot be opened.
    Obviously ACDSee and other picture viewing programs are installed in my computer.
    The corresponding application code can be found at the bottom of the page of http://www.awprofessional.com/articles/article.asp?p=661371&seqNum=2&rl=1
    my code:
    if(Desktop.isDesktopSupported()){
    Desktop desktop=Desktop.getDesktop();
    try
    desktop.open (fileToOpen);
    catch (IOException ioe)
    JOptionPane.showMessageDialog (frame,
    "I/O problem");
    catch (IllegalArgumentException iae)
    JOptionPane.showMessageDialog (frame,
    "File doesn�t exist");
    fileToOpen is obviously a File.
    Thx for the help in advance.

    Hello Ercoupe. Welcome to Apple Discussions.
    If this is being caused by an overly large Mailbox, click on the link below provided by Allan Sampson, for a possible solution.
    MBOX Breaker Script
    Message was edited by: roam

  • Plobrem in Desktop API , please help me!

    Hi all,
    I'm trying to write a desktop add-in to sync address data between PC and BB device(8707).
    But when I exec the DesktopSample code, I have two big problem.
    I tried in Desktop Manager version4.2.2, 4.3.0, but same plobrem has happen...
    <Problem 1> Get address book list from BB device
    The Count value of IRimRecordsPtr is always 0.
    This will happen, when the address data was written with Japanese.
    In English, this problem is not happen.
    <Problem 2> Send address book data to BB device
    The address data, witch was written by Japanese, characters are garbled.
    So I can't read.
    I have changed the character code to "Shift-JIS", "UTF8", " UTF16-BE"
    but still garbled...
    These problems happens in Japanese.
    In English, problem is not happen.
    Is there anything that I have to do for?
    Is Desktop API support MulitiByte code?
    Please advice me!
    thanks.

    I have tried that already but the Itunes logo appears. It is currently connected to my laptop and iTunes but the iTunes logo is still there and it wants me to Restore it.. Which means I am going to lose everything?
    Come on, we are in the year 2011! There needs to be a way I can restore all my picture/videos and all my important work documents, right, without losing it?!
    (wispers - iPhone has failed me once again)

  • What is the problem when opening jpg files using Desktop API

    Hi, i would like to open jpg, or gif files using Desktop API, and the application crashes.The Desktop API is supported by my OS, because txt files, or file directories can be opened, mails can be sent, browsing is also supported.
    Only jpg and gif, and i think other picture formats cannot be opened.
    Obviously ACDSee and other picture viewing programs are installed in my computer.
    The corresponding application code can be found at the bottom of the page of http://www.awprofessional.com/articles/article.asp?p=661371&seqNum=2&rl=1
    my code:
    if(Desktop.isDesktopSupported()){
    Desktop desktop=Desktop.getDesktop();
    try
    desktop.open (fileToOpen);
    catch (IOException ioe)
    JOptionPane.showMessageDialog (frame,
    "I/O problem");
    catch (IllegalArgumentException iae)
    JOptionPane.showMessageDialog (frame,
    "File doesn�t exist");
    fileToOpen is obviously a File.
    Thx for the help in advance.
    Message was edited by:
    javahelps
    Message was edited by:
    javahelps
    Message was edited by:
    javahelps
    Message was edited by:
    javahelps

    My file association for jpg files is correct, if i click on a
    jpg, ACDSee starts immediately.Although I am a long time Windoze non-user, I vaguely remember that there's a difference between correct file-type association being set and some application starting at a mouse click on a file icon. I also vaguely remember Windoze file-type association mechanism uses a few action-types. Java Desktop should expect a specific action-type for the association.

  • Desktop API functionality in newer Skype version (...

    I work for a company that uses Desktop API to enable our devices to use call controls in Skype Desktop.  All seems to be working up to Skype version 6.20.0.104.  Newer version of Skype still have support, but returns values are now unexpected, and has broken our solution.
    Consider the code below snippet for holding a call.  I check if the active call has clsInProgress status.  With newer version of Skype, the status is always clsRinging.
    ICallCollectionPtr calls = m_pSkype_->ActiveCalls;
    int numCalls = calls->Count;
    for(int index=1;index<=numCalls;index++)
        ICallPtr call = calls->Item[index];
        TCallStatus status = call->GetStatus();
        if (status == clsInProgress)
            //[HandleCallRequest] - CallRequestHold
            hr = call->Hold();
            break;
    I would normally post to developer community, but this site no longer exists. Can someone who knows please respond, or suggest an alternate action?
    I appreciate the response.
    Solved!
    Go to Solution.

    This is a known issue in the latest 6.22 and 7.0 versions.
    http://community.skype.com/t5/Windows-desktop-client/SKYPE4COM-CallStatus-event-no-longer-working/m-...

  • Group Calling: APP vs Desktop API

    When I start a group call in the desktop API, if one party does not answer and it starts going to voicemail, I can hang up on just that one party while still talking to other participants. In the skype app for windows 8, that option does not appear available. If one party doesn't answer and it starts going to voicemail, I have to end the call for the whole group. Is there a way around this?

    http://sourceforge.net/projects/jacob-project/

  • Access denied when using Desktop-API

    Hi to all,
    I have a client app that is launched using JWS. In my JNLP file I declared:
    <security>
         <j2ee-application-client-permissions/>
    </security>
    and all jar-files are signed with the same certificate. This is working fine, but when I try to use the Desktop-API to open a folder on clients machine
    Desktop.getDesktop().open(new File("/path/to/dir"));
    it gives me
    java.security.AccessControlException: access denied (java.io.FilePermission <<ALL FILES>> execute)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.awt.Desktop.checkExec(Unknown Source)
         at java.awt.Desktop.open(Unknown Source)
    I even tried with
    <security>
         <all-permissions/>
    </security>
    in JNLP. But it gives me the same Exception. I also tried to use a PrivilegedAction to make SecurityManager not check permissions, but it didn't help. At last thought about having my own policy-file. But I don't know how to tell the JWS app to use it.
    Thanks for help in advance
    Christian

    Hi to all,
    Deleting the cache works fine. But only for one start.
    I found the JNLP in the cache has been automatically updated with the line
    <update check="timeout" policy="always"/>
    I thought this could be the problem, because if may be the SecurityManager finds JNLP in the cache being different from that one on the server, it "thinks" it has been hacked?
    To avoid this difference, I added the line right from the beginning, but that didn't help.
    BTW I signed all my jars, but the JNLP-File is just provided in the working dir of the app unsigned. Somewhere I read about JNLP-Files also signed. May be I have to sign it, too, or is it possible to have it packed in my application jar (then it will be signed with it)?
    Thank for any hints
    Christian

  • Where can I download the Skype Desktop API?

    Title says it all.

    Skype4Com.dll desktop API library is installed with each Skype installation. There is no separate download for this DLL module.

  • Adding desktop API to java swings

    Hi,
    I want to open the default web browser through java. So, I used desktop api to open the default web browser and its working fine also.
    I tried like this:
    if(desktop.isDesktopSupported())
                        desktop.getDesktop().browse(new URI("http://www.aamec.com"));
    Now, I want to add the opened file to internal frame of my application. I tried using add() but it's not working..
    Pls help me out..
    Thanks in advance,
    M.Sivapreeya

    SATSA API is not available with wireless toolkit 2.2. Why dont u try Wireless Toolkit 2.3 Beta version, there SATSA is available as an optional pacakge.

  • Desktop API Gnome libraries

    Hi,
    Documentation says
    Use the Desktop.isDesktopSupported() method to determine whether the Desktop API is available. On the Solaris Operating System and the Linux platform, this API is dependent on Gnome libraries. If those libraries are unavailable, this method will return false
    Any idea what these libraries are ? I am specifically looking for the gnome libraries required.

    I figured it out. In Fedora, you need to install libgnome library (I used sudo yum install libgnome)

  • Using the Desktop API in Java SE 6 (Mustang)

    <p>The Java platform continues to evolve, and Java applications can now integrate with the host desktop better than ever before. This new article describes how to integrate your Java application into the desktop using new Java SE 6 features:</p>
    http://java.sun.com/developer/technicalArticles/J2SE/Desktop/mustang/desktop_api/

    peterwkc wrote:
    Hello to all,
    this is some sort of theoretical question.
    I been reading the JMS documentation for a while.
    1.I could not understand what this statement means :
    >
    This section describes the ways in which using the JMS API in enterprise bean applications or web applications differs from using it in application clients.
    What a developer is allowed to do is different depending on whether they are writing code to run in a container or not. The container already provides lots of services so some code you would write for outside a container is not needed when you write for a container. There are APIs that you are not allowed for in container code if you want to adhere to the spec.
    >
    2. What is the difference to use the JMS in java EE web orEJB container and application client ?
    Thanks.Read more of that document to find out the differences. Application components in Web/EJBs must not create more than one active session per connection while application clients are allowed to do so.

  • File uri with query string can't be propagated by desktop.browse()

    I have been trying to show some help pages using the following command:
    java.awt.Desktop.getDesktop().browse( helpURI);
    while the helpURI.toString() prints out the following:
    file:///C:/Share/Code/phoenix/Install/REDIST/Help_Files/en/wwhelp/wwhimpl/js/html/wwhelp.htm?context=BD&href=Chapter%202%20-%20Configuration.1.14.html
    But when the getDesktop().browse() API is executed it will only propagate the uri-path and not the query string.
    So the browser shows the following url as a result of the browse() call:
    C:\Share\Code\phoenix\Install\REDIST\Help_Files\en\wwhelp\wwhimpl\js\html\wwhelp.htm
    But if I manually copy the string "file:///C:/Share/Code/phoenix/Install/REDIST/Help_Files/en/wwhelp/wwhimpl/js/html/wwhelp.htm?context=BD&href=Chapter%202%20-%20Configuration.1.14.html" to the internet explorer it works fine.
    So can somebody give me any guidance on how I can propagate the file uri with query string through the browse() API or is there a better API for that?
    Sibon.

    The "cmd /S /C" suggestion didn't seem to work. I don't think the problem is in java but how the command line parameter needs to be added from msdos shell to "iexplore.exe"
    When from the command line I enter the following command:
    iexplore.exe file:///C:/Share/Code/phoenix/Install/REDIST/Help_Files/en/wwhelp/wwhimpl/js/html/wwhelp.htm?context=BD&href=Chapter%202%20-%20Configuration.1.14.html
    I get the same result as invoking from java Desktop API --- it truncates everything from question mark. I tried palying around with double quotes, single quotes, escaping and nothing seem to work.
    Any ideas?

  • Skype api with google spreadsheets

    Hello,
    I want  to integrate skype call from my google spreadsheets, by clicking on the phone number which I have already saved in the sheet.
    Any body can say how I integrate this.
    waiting for your response.
    Arka

    Well, as you say, the Skype API is unsupported but is still in there... so I played around a bit and got something that works (today, with version 7.5, with the moon in its current phase).
    The following script is poorly written, but works:
    set userList to "skypeuser1, skypeuser2, echo123"
    set messageToSend to "Hey, it works!"
    tell application "Skype"
        set chatIDString to send command "CHAT CREATE " & userList & space script name "skype_messages.scpt"
        set chatID to character id 35 & (word 2 of chatIDString) & "/" & (word 3 of chatIDString) & (word 4 of chatIDString)
        send command "CHATMESSAGE " & chatID & space & messageToSend script name "skype_messages.scpt"
    end tell
    Basically, what you're doing is creating a new chat session, which returns the following string:
    "CHAT #yourusername/$c14a201aac174943 STATUS MULTI_SUBSCRIBED"
    The trouble is the CHATMESSAGE command wants only part of that string, from the hash mark (#) to the end of that hex string. AppleScript was giving me headaches about parsing that string as words to get the bits I wanted, so that's why there's the code where I save off the parts I need, and then rebuild them as a chat ID.
    And, as far as I can tell, the name of the script in each Skype command can be anything, but it has to be there.
    Hope this helps,
    Mike
    P.S. Almost forgot... you can get the Skype API reference guide from the Wayback Machine at http://web.archive.org/web/20130607130426/http://d​ev.skype.com/desktop-api-reference#COMMANDS

  • Desktop.browse() won't show URI fragments on Windows

    Hi. I'd like to use the Desktop API in my application when the user clicks on various 'help' buttons. My reference manual for the application is one large HTML file, and so if the user clicks on a 'help' button when he's in the 'configuration' menu, for example, I want to be able to do something like this:
      desktop.browse (java.net.URI.create ("file:/c:/html/help.html#configuration"))... so his browser will go straight to the 'configuration' part of the HTML file, as per the "#configuration" fragment part of the URI.
    Unfortunately I can't get Internet Explorer to work with URL fragments. If I use the above bit of code Explorer will start properly and display the html file ... but remain at the very top of the file.
    Yet the code works fine under Linux (KDE runs up Konqueror and goes straight to the tagged 'configuration' section).
    There are no errors, no exceptions thrown, and Internet Explorer does properly run and display the HTML file ... it simply stays at the very top of the file.
    I also note that, in the address box (I'm probably using the wrong name for it - the text area where one can manually type in a URL in a browser) only the part of the URL without the fragment is listed ... even though the program calls desktop.browse() with the full URI including the "#configuration" fragment tail. It's as if something is stopping Explorer from 'noticing' or registering the fragment part of the URI.
    Can anyone help?

    I tried using URLs with the "Run" prompt in Windows XP SP2 with Firefox and Internet Explorer 7 and they work just fine if launched in the format:
    iexplore http://code.google.com/apis/analytics/docs/gdata/gdataAppEngine.html#retrievingData
    "C:\Program Files\Firefox\firefox.exe" http://code.google.com/apis/analytics/docs/gdata/gdataAppEngine.html#retrievingDataI haven't tried it with the Desktop class.
    Note, I also tried using a "%23" in place of the "#" as a potential work-around, but it doesn't seem to work.
    Edit:
    I was able to reproduce the issue using the following sample html file:
    <html>
    Testing...
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <h1><a name="1"/>Bookmark #1</h1>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <h1><a name="2"/>Bookmark #2</h1>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <h1><a name="3"/>Bookmark #3</h1>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <h1><a name="4"/>Bookmark #4</h1>
    </html>In my tests, Internet Explorer DOES NOT automatically scroll to the page marker.
    iexplore  file:///C:/Documents%20and%20Settings/Administrator/Desktop/test.html#1Firefox DOES automatically scroll to the page marker.
    "c:\Program Files\Firefox\firefox.exe"  file:///C:/Documents%20and%20Settings/Administrator/Desktop/test.html#1Have you tried using a default browser other than Internet Explorer? In both cases, the "#" does not get stripped off.
    -Tres

  • Desktop.open() fails when file contains German umlauts

    Hello,
    I want to open a file using the Desktop-API:
    // check whether opening a file is supported or not
    if (!desk.isSupported(Desktop.Action.OPEN)) {
      // display error message box
      JOptionPane.showMessageDialog(getFrame(),getResourceMap().getString("errLinkUnsopportedMsg"),
             getResourceMap().getString("errLinkUnsopportedTitle"),JOptionPane.ERROR_MESSAGE);
      return;
    desk.open(linkfile);I'm catching all possible exceptions here:
                 catch (IOException e)
                catch (IllegalArgumentException e)
                catch (SecurityException e)
                catch (UnsupportedOperationException e)
                catch (URISyntaxException e)But when I want to open a file that contains German umlauts, my application throws following exception:
    Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException:
    Non-Java exception raised, not handled!
    (Original problem: *** -[NSCFArray initWithObjects:count:]:
    attempt to insert nil object at objects[0])
    at apple.awt.CDesktopPeer._lsOpen(Native Method)
    at apple.awt.CDesktopPeer.lsOpen(CDesktopPeer.java:53)
    at apple.awt.CDesktopPeer.open(CDesktopPeer.java:33)
    at java.awt.Desktop.open(Desktop.java:254)
    at zettelkasten.ZettelkastenView.eventHyperlinkActivated(ZettelkastenView.java:9609)
    at zettelkasten.ZettelkastenView.access$6000(ZettelkastenView.java:119)
    at zettelkasten.ZettelkastenView$14.hyperlinkUpdate(ZettelkastenView.java:7014)The file does definitely exist. I chose it with a filechooser, and I debugged the source step-by-step. Before calling the desktop.open() command, I check whether the file exists or not (File.Exists()).
    When I open any file without umlauts, everything is fine. Only files with umlauts in their filename seem to make trouble.
    My OS is:
    Mac OS X 10.5.5, running the latest Java 6, using NetBeans 6.5
    Is there any solution, or at least a workaround?
    Thanks in advance!
    Daniel
    Edited by: DnlLdck on Jan 29, 2009 6:23 AM

    Same thing happened to me, but I was trying to browse an URI which contains non-English characters. Haven't try it on Windows yet. Maybe it does not support non-English characters on Mac.

Maybe you are looking for