Desktop class

Hey
I am trying to print a document using the new java class Desktop class.
Desktop desktop = null;
if (Desktop.isDesktopSupported())
desktop= Desktop.getDesktop();
try {
desktop.print(new File(aFileFullPath));
catch (IOException e)
// TODO Auto-generated catch block
e.printStackTrace();
if(desktop.isSupported(Desktop.Action.PRINT))
System.out.println("print supported");
I get no exception running the code and also the "print supported" message is been displayed, but nothing happens, the file is not printed! I was trying also the command for open a file and the same result, no exceptions and no operation are been taken.
I was trying to run the Desktop example: http://download.oracle.com/javase/tutorial/uiswing/misc/desktop.html
But same result, the project is running but no operations are taken.
The only thing I found regarding this issue is Changing File Associations, but for example If I am trying to print or open a .DOC file under windows the system already associate the file with Microsoft Word application...
Thanks,Natalie
Edited by: 799847 on Feb 27, 2011 2:49 AM

799847 wrote:
..I am trying to print a document using the new java class Desktop class.
Desktop desktop = null;When posting code, code snippets, HTML/XML or input/output, please use the code tags as described on the 'sticky post' at the top of the forum thread listing. E.G.
Desktop desktop = null;
  if (Desktop.isDesktopSupported())
   desktop= Desktop.getDesktop();
   try {
          desktop.print(new File(aFileFullPath));
   catch (IOException e)
     // TODO Auto-generated catch block
    e.printStackTrace();
   if(desktop.isSupported(Desktop.Action.PRINT))
     System.out.println("print supported");
I get no exception running the code and also the "print supported" message is been displayed, but nothing happens, the file is not printed! I was trying also the command for open a file and the same result, no exceptions and no operation are been taken.
I was trying to run the Desktop example: http://download.oracle.com/javase/tutorial/uiswing/misc/desktop.html
Smells like a bug to me. Check the bug database for similar bugs and if you do not find one, raise a new report. Use the DesktopDemo.java as the source for the report. There is nothing quite more definitive than Oracle's own demo. code!
BTW - I am guessing you edited your post? If so, you went about it the wrong way. If the 'back button' is used to edit a post, it results in 2 posts. Instead use the 'edit' link on the top right of the last message. Note that I would have replied sooner, but first I wanted to ensure the other post was deleted so people do not waste time replying to 2 threads. 0_o
Added to that, the reply was further delayed by me having to type that. ;)

Similar Messages

  • Installer hanging on selecting Desktop Class

    Morning,
    I downloaded the 32 bit Windows 11.2.0.3 patchset from My Oracle Support early on in the week. When I try to install it on a Windows 7 machine, the installer hangs on the 'Installing Database' page after I select 'Desktop Class' and press the Next button.
    I had earlier chosen to skip software updates and the create and install a starter database option.
    Has anyone else experienced this, are there any log files created by the installer at this point that I can look at or can anyone help with a solution?

    Thanks Srini,
    I can confirm I have met all the pre-requirements and don't have spaces in the folders.
    The machine being installed on is Windows 7 SP1
    Here are the lines from the log file:
    INFO: Localizing view <AutoUpdatesOptionsUI> at state <AutoUpdatesOptionsUI>
    INFO: Completed localizing view <AutoUpdatesOptionsUI> at state <AutoUpdatesOptionsUI>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Executing action at state AutoUpdatesOptionsUI
    INFO: Completed executing action at state <AutoUpdatesOptionsUI>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Moved to state <AutoUpdatesOptionsUI>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Validating view at state <AutoUpdatesOptionsUI>
    INFO: Completed validating view at state <AutoUpdatesOptionsUI>
    INFO: Validating state <AutoUpdatesOptionsUI>
    INFO: Completed validating state <AutoUpdatesOptionsUI>
    INFO: No updates will be downloaded or applied
    INFO: Verifying route NO_AUTO_UPDATES
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Executing action at state supportedOSCheck
    INFO: Completed executing action at state <supportedOSCheck>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Moved to state <supportedOSCheck>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Validating view at state <supportedOSCheck>
    INFO: Completed validating view at state <supportedOSCheck>
    INFO: Validating state <supportedOSCheck>
    INFO: Verifying target environment...
    INFO: Checking whether the IP address of the localhost could be determined...
    INFO: Completed verification of target environment.
    INFO: Completed validating state <supportedOSCheck>
    INFO: Verifying route success
    INFO: Get view named [InstallOptionsUI]
    INFO: InstallOptionsUI Entering Constructor
    INFO: InstallOptionsUI Exiting Constructor
    INFO: View for [InstallOptionsUI] is oracle.install.ivw.db.view.InstallOptionsUI@19713ea
    INFO: Initializing view <InstallOptionsUI> at state <installOptions>
    INFO: Completed initializing view <InstallOptionsUI> at state <installOptions>
    INFO: Displaying view <InstallOptionsUI> at state <installOptions>
    INFO: Completed displaying view <InstallOptionsUI> at state <installOptions>
    INFO: Loading view <InstallOptionsUI> at state <installOptions>
    INFO: Completed loading view <InstallOptionsUI> at state <installOptions>
    INFO: Localizing view <InstallOptionsUI> at state <installOptions>
    INFO: Completed localizing view <InstallOptionsUI> at state <installOptions>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Executing action at state installOptions
    INFO: Completed executing action at state <installOptions>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Moved to state <installOptions>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: InstallOptions UI Entering & Exiting processInput
    INFO: Validating view at state <installOptions>
    INFO: Completed validating view at state <installOptions>
    INFO: Validating state <installOptions>
    INFO: inventory location isC:\Program Files\Oracle\Inventory
    INFO: Is CRS Installed false
    INFO: Completed validating state <installOptions>
    INFO: InstallOptionsAction Actions.transition called
    INFO: selectedInstallOption is :INSTALL_DB_AND_CONFIG
    INFO: inventory location isC:\Program Files\Oracle\Inventory
    INFO: Is CRS Installed false
    INFO: launchNETCA = true
    INFO: Verifying route system_class
    INFO: Get view named [SystemClassUI]
    INFO: SystemClassUI Entering Constructor
    INFO: SystemClassUI Exiting Constructor
    INFO: View for [SystemClassUI] is oracle.install.ivw.db.view.SystemClassUI@6c9220
    INFO: Initializing view <SystemClassUI> at state <getSystemClass>
    INFO: inventory location isC:\Program Files\Oracle\Inventory
    INFO: Is CRS Installed false
    INFO: Completed initializing view <SystemClassUI> at state <getSystemClass>
    INFO: Displaying view <SystemClassUI> at state <getSystemClass>
    INFO: Completed displaying view <SystemClassUI> at state <getSystemClass>
    INFO: Loading view <SystemClassUI> at state <getSystemClass>
    INFO: Completed loading view <SystemClassUI> at state <getSystemClass>
    INFO: Localizing view <SystemClassUI> at state <getSystemClass>
    INFO: Completed localizing view <SystemClassUI> at state <getSystemClass>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Executing action at state getSystemClass
    INFO: Completed executing action at state <getSystemClass>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Moved to state <getSystemClass>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: SystemClassUI Entering & Exiting processInput
    INFO: Validating view at state <getSystemClass>
    INFO: Completed validating view at state <getSystemClass>
    INFO: Validating state <getSystemClass>
    INFO: inventory location isC:\Program Files\Oracle\Inventory
    INFO: Is CRS Installed false
    INFO: Completed validating state <getSystemClass>
    INFO: selectedSystemClass is :DESKTOP_CLASS
    INFO: inventory location isC:\Program Files\Oracle\Inventory
    INFO: Verifying route desktop_class_yes
    INFO: Get view named [QuickInstallUI]

  • Desktop class problem

    The code below does nothing. No file opened, no exception thrown, no output.
    What can I do to discover the problem?
    It does indeed execute the desktop.open(file) line.
    Using JDK 1.16.0_81
    File file = new File(pathAndFileString); // an existing text file
    if (Desktop.isDesktopSupported()) {
         Desktop desktop = Desktop.getDesktop();
         if (desktop.isSupported(Desktop.Action.OPEN )) {
              try {
                   desktop.open(file);
              } catch (IOException e1) {
                   e1.printStackTrace();
         else {
              System.out.println("Desktop.Action.OPEN not supported");
    else {
         System.out.println("Desktop not supported");
    }

    package desktopdemo;
    import java.awt.Desktop;
    import java.io.File;
    import java.io.IOException;
    public class MyDesktopDemo {
         public MyDesktopDemo() {
              // have tried .txt, .rtf, .pptx all with no effect
              String pathAndFileString = "C:\\my.pptx";
              File file = new File(pathAndFileString);
              if (Desktop.isDesktopSupported()) {
                   Desktop desktop = Desktop.getDesktop();
                   if (desktop.isSupported(Desktop.Action.OPEN )) {
                        try {
                             System.out.println("desktop.open(" + pathAndFileString + ")"); // gets here
                             desktop.open(file); // but nothing happens
                        } catch (IOException e1) {
                             e1.printStackTrace();
                   else {
                        System.out.println("Desktop.Action.OPEN not supported");
              else {
                   System.out.println("Desktop not supported");
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new MyDesktopDemo();
    }

  • Can't print using Desktop class

    I found some code to print out a text file at this site:
    http://www.java2s.com/Code/Java/CatalogJava.htm
    import java.awt.Desktop;
    import java.io.File;
    import java.io.IOException;
    public class print
      public static void main(String[] a)
        try
          Desktop desktop = null;
          if (Desktop.isDesktopSupported())
            desktop = Desktop.getDesktop();
          File f = new File("C:\\a.txt");
          desktop.print(f);
        catch (IOException ioe)
          ioe.printStackTrace();
    }but I get this run time message:
    C:\java>javac print.java
    C:\java>java print
    java.io.IOException: Failed to print file:/C:/java/graphics.java. Error message:
    No application is associated with the specified file for this operation.
    at sun.awt.windows.WDesktopPeer.ShellExecute(Unknown Source)
    at sun.awt.windows.WDesktopPeer.print(Unknown Source)
    at java.awt.Desktop.print(Unknown Source)
    at print.main(print.java:16)
    What is wrong with the code?
    Regards
    Chris

    I've got XP/SP2 here, so your mileage might vary.
    When I looked I saw that .java files were configured to open with Notepad ie there was an "open" entry in the menu when you right clicked on them, and Notepad would start when you double clicked on them.
    When I compiled and ran your program (changing the file name) this is what I saw:
        C:\>javac -cp . A.java
        C:\>java -cp . A\\    java.io.IOException: Failed to print file:/C:/A.java. Error message: The paramet\\    er is incorrect.
                at sun.awt.windows.WDesktopPeer.ShellExecute(Unknown Source)\\            at sun.awt.windows.WDesktopPeer.print(Unknown Source)\\            at java.awt.Desktop.print(Unknown Source)\\            at A.main(A.java:16)
        C:\>Here's how I registered Notepad to print .java files: From Windows Explorer I choose "Tools" then "Folder Options". In the "File Type" tab I scrolled down to "JAVA" - the file types are listed alphabetically b extension - and then clicked the "Advanced" button. From there you are able to add a new action. Actions are the things that appear in the context menu when you right click an icon in Windows Explorer. In fact I added two actions: open and print.
    For instance to print the application was
        C:\WINDOWS\System32\NOTEPAD.EXE /p %1
    Use DDE was ticked, the application was set to NOTEPAD and the Topic was System. The open action was the same except that the application lacked the /p part. I added the open action before the print action.
    (I should explain that I added both and choose the settings I did by looking at how TXT files were already set up in the "File Type" pane of the "Folder Options" dialog).
    After closing and OKing everything, I ran the program again.
        C:\>java -cp . A
        C:\>This time the file printed OK.

  • Unable to install 11g R2 Database(desktop class) on Windows 7 professional

    Hello,
    I have downloaded Oracle 11g Release 2 and try to install on Windows 7 Professional (x64) and it is giving the following error .
    Appreciate if any someone can resolve.
    Expected Value
     : n/a
    Actual Value
     : n/a
     List of errors:
    PRVF-7531 : Physical memory check cannot be performed on node "Tanweer-PC"  - Cause:  Could not perform check of physical memory on the node indicated.  - Action:  Ensure ability to access the node specified and view memory information.
    Edited by: Tanweer on 20 Mar, 2011 8:31 AM

    Here output from the install log files:-
    INSTALL_TYPE EE
    MYORACLESUPPORT_PASSWORD Protected value, not to be logged
    MYORACLESUPPORT_USERNAME
    ORACLE_BASE
    ORACLE_HOME
    ORACLE_HOSTNAME Tanweer-PC
    PROXY_HOST
    PROXY_PORT
    PROXY_PWD Protected value, not to be logged
    PROXY_USER
    SECURITY_UPDATES_VIA_MYORACLESUPPORT true
    SELECTED_LANGUAGES {"en"}
    b_rdbmsInstall true
    oracle.install.db.isCCRAuthenticationUsed false
    oracle_install_LaunchNetCA false
    oracle_install_NoMigration false
    oracle_install_OCR_PartitionLocation
    oracle_install_RACInstall false
    oracle_install_RDBMSInstalling true
    oracle_install_client_OraMTSPortNumber 49156
    oracle_install_db_ASMSNMPUserPassword Protected value, not to be logged
    oracle_install_db_AutoMemoryOption false
    oracle_install_db_CharSetOption 3
    oracle_install_db_CharacterSet
    oracle_install_db_ConfigTabSelected 0
    oracle_install_db_ConfigurationType &General Purpose / Transaction Processing
    oracle_install_db_CustomInstall false
    oracle_install_db_DiskGroupName
    oracle_install_db_DiskGroupNameForASM
    oracle_install_db_EMCentralAgentSelected
    oracle_install_db_EMEmailAddress
    oracle_install_db_EMSMTPServer
    oracle_install_db_EnableAutoBackup false
    oracle_install_db_InstallEdition EE
    oracle_install_db_InstallOption INSTALL_DB_AND_CONFIG
    oracle_install_db_InstallOptionSelected 1
    oracle_install_db_InstallType EE
    oracle_install_db_LaunchDBCA false
    oracle_install_db_LaunchODMA false
    oracle_install_db_LoadExampleSchemas false
    oracle_install_db_MountPointLocation
    oracle_install_db_QuickInstallOption false
    oracle_install_db_ReceiveEmailNotification false
    oracle_install_db_RecoveryBackUpLocation
    oracle_install_db_RecoveryBackUpPassword Protected value, not to be logged
    oracle_install_db_RecoveryBackUpUsername
    oracle_install_db_SID
    oracle_install_db_SecureConfigDisabled false
    oracle_install_db_SetOracleBase false
    oracle_install_db_StarterDatabaseType GENERAL_PURPOSE
    oracle_install_db_StorageType 0
    oracle_install_db_SuperAdminPasswords Protected value, not to be logged
    oracle_install_db_SuperAdminSamePasswdForAll Protected value, not to be logged
    oracle_install_db_SystemClass DESKTOP_CLASS
    oracle_install_db_Type 1
    oracle_install_db_UseDBControl true
    oracle_install_db_UseFileSystemForRecovery false
    oracle_install_db_UseSamePassword false
    INFO: Launching Oracle Database 11g Release 2 Installer
    INFO: Started executing the flow in INTERACTIVE mode
    INFO: Waiting for completion of background operations
    INFO: Finishing all forked tasks at state prepInstall
    INFO: Waiting for completion all forked tasks at state prepInstall
    INFO: All forked task are completed at state prepInstall
    INFO: Completed background operations
    INFO: Executing action at state prepInstall
    INFO: Completed executing action at state <prepInstall>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Moved to state <prepInstall>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Validating view at state <prepInstall>
    INFO: Completed validating view at state <prepInstall>
    INFO: Validating state <prepInstall>
    WARNING: Validation disabled for the state prepInstall
    INFO: Completed validating state <prepInstall>
    INFO: Verifying route success
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Executing action at state decideOCMInstall
    INFO: Completed executing action at state <decideOCMInstall>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Moved to state <decideOCMInstall>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Validating view at state <decideOCMInstall>
    INFO: Completed validating view at state <decideOCMInstall>
    INFO: Validating state <decideOCMInstall>
    WARNING: Validation disabled for the state decideOCMInstall
    INFO: Completed validating state <decideOCMInstall>
    INFO: Verifying route requireOCM
    INFO: Get view named [OCMDetailsUI]
    INFO: View for [OCMDetailsUI] is oracle.install.ivw.common.view.OCMDetailsGUI@5f159e0c
    INFO: Initializing view <OCMDetailsUI> at state <getOCMDetails>
    INFO: Completed initializing view <OCMDetailsUI> at state <getOCMDetails>
    INFO: Displaying view <OCMDetailsUI> at state <getOCMDetails>
    INFO: Completed displaying view <OCMDetailsUI> at state <getOCMDetails>
    INFO: Loading view <OCMDetailsUI> at state <getOCMDetails>
    INFO: Completed loading view <OCMDetailsUI> at state <getOCMDetails>
    INFO: Localizing view <OCMDetailsUI> at state <getOCMDetails>
    INFO: Completed localizing view <OCMDetailsUI> at state <getOCMDetails>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Executing action at state getOCMDetails
    INFO: Completed executing action at state <getOCMDetails>
    INFO: Waiting for completion of background operations
    INFO: Completed background operations
    INFO: Moved to state <getOCMDetails>

  • How do I configure portal desktop to use my own custom tag in template?

    I seem to have tried everything. I want to use a custom tag from a jar file on a template JSP. I keep getting error saying tag library not found. I have the tld in the meta-inf of the jar. I tried putting the jar in the desktop classes, the deployed WEB-INF lib directory for portal, in the web-src directory for the portal. I tried configuring the uri in the web.xml for the portal webapp. None of these have worked. Does someone know how to do this? If someone could help out that would be great. I tries the jar from a web application and it worked fine. I just need to get this working with Portal Server.
    Thanks,
    Frank

    Thank you for the reply Alex. We are using the Dynamics AX 2012 R3 ISO for our installation. In the software requirement documentation for Dynamics AX it says that is able to run on Windows Server 2012 R2. I believe the prerequisites for Dynamics AX and
    Dynamics CRM are different. We received a response from another forum that you can change the .NET version that Sharepoint 2010 uses through IIS in the application pool, but even after setting it to .NET v2.0, we still receive the error in the Dynamics log
    that says it is not compatible with .NET v4.0. So I suppose the question is, where does the Dynamics AX 2012 R3 prerequisite checker look to see which version of .NET Sharepoint is using?
    Thanks again for the reply!

  • Desktop.open() Problem

    I recently put together an application that relied heavily on the Desktop.open( ) method and several other methods from the Desktop class. However, all of a sudden the Desktop.open() does not work. I believe I read some where that this was due to the ShellExecute function or dll or something like that.
    However, since my app is targetted at the Windows platform I resorted to using windows Explorer to launch the system default applications for files using a the code below
    public static void openFile(File file) {
      try {
        Runtime runtime = Runtime.getRuntime();
        runtime.exec( "explorer.exe \"" + file.getAbsolutePath() + "\"" );
      } catch(IOException) {
        ioe.printStackTrace();
        JOptionPane.showMessageDialog(null, "Could Not Open File Location: " + file.getAbsolutePath());
    }The code works as expected, but my problem is that I am loosing cross-platform functionality.
    Can any point my to solution to this Desktop.open( ) problem, or probably add the my list platform dependent launch procedures so at least the code works on Windows,Linux and Mac.
    ICE

    Thanks Andrew,
    I've do a more simple example of the problem. I create two files on "\\fiuu\proyectosShared", one called "test.txt" and the other one called "te st.txt". I execute your exact source for the who paths whith these results:
    File f = new File("//fiuu/proyectosShared/test.txt");
    System.out.println(f + "  exists: " + f.exists());
    dt.open(f);
    RESULT:
    \\fiuu\proyectosShared\test.txt  exists: true
    (notepads opens the file)The second test does'nt work:
    File f = new File("//fiuu/proyectosShared/te st.txt");
    System.out.println(f + "  exists: " + f.exists());
    dt.open(f);
    RESULT:
    \\fiuu\proyectosShared\te st.txt  exists: true
    Exception in thread "main" java.io.IOException: Failed to open file:////fiuu/proyectosShared/te%20st.txt. Error message: El sistema no puede hallar la ruta especificada.
         at sun.awt.windows.WDesktopPeer.ShellExecute(WDesktopPeer.java:59)
         at sun.awt.windows.WDesktopPeer.open(WDesktopPeer.java:36)
         at java.awt.Desktop.open(Desktop.java:254)
         at DesktopTest.main(DesktopTest.java:14)
    (translation of error message: System can't find specified path)I've also done some tests with Desktop.browse(file.toURI), and some others with no success.
    Something curious: try to execute Runtime.getRuntime().exec("explorer " + f.getAbsolutePath) for a file that has thow white spaces on his name....
    File f = new File("//fiuu/proyectosShared/te  st.txt");//with two white spaces
    System.out.println(f + "  exists: " + f.exists());
    Runtime.getRuntime().exec("explorer " + f.getAbsolutePath());
    \\fiuu\proyectosShared\te  st.txt  exists: trueSystem says:
    Explorador de Windows
    La ruta '\\fiuu\proyectosShared\te st.txt' no existe o no es un directorio.
    Aceptar  
    (spanish version of File not found alert message)Note that in alert message one white space of filename is lost!
    Thanks again
    Edited by: pakomail on Nov 24, 2008 6:12 AM

  • How to use java class in jsp page of JSPProvider?

    Hello everybody.
    I created simple JSPProvider channel with portal amconsole and named it "jspprov1". Then I created "jspprov"1 directory under "/ets/opt/SUNWps/desktop/sampleportal". I put "index.jsp" in it. And it worked until I add this line into "index.jsp": <% @page import="jspprov1package.aclass1" %>. Then I created directory "jspprov1package" under "/ets/opt/SUNWps/desktop/classes" and put "aclass1.class" into it and into "/ets/opt/SUNWps/desktop/classes" itself. I created "aclass1.class" on the other machine (with no installed portal) in j2sdk1.4.1_02: "javac aclass1.java". The text of this class is simple:
    "package jspprov1package;
    public class aclass1{
    public int int_field = 10;
    But the page still don't work. It writes on the portal desktop "ERROR: Content is not available".
    Does anybody know why this happened?

    Sorry, there were mistakes in jsp page and java files.
    I maked the channel "show exceptions" and found them out.

  • Need Classes help......

    Hi all,
    i was wondering if anyone can help me out with my code.
    i've got a class Desktop, and a class menu.
    the class Desktop contains the following...
    public class Desktop extends JFrame implements ActionListener{
    protected JDesktopPane  thedesktop;
    protected JMenuBar jMenuBar1;
    protected ..........and all elements declared here..
    public Desktop(){
    super("application");
    menu mymenu = new menu(); //class will build the menubar
    setJMenuBar(jMenuBar1); //adds menubar to jframe
    bla bla.......
    public static void main(String args[]){
    Desktop app = new Desktop(); //call constructor
    }the class menu is as follows
    public class menu extends Desktop{
    public menu() {
    jmenubar1 = new JMenuBar();
    //add all items to jmenubar1
    //all menus etc are declared in desktop, and initalized here
    // as this class extends desktop class
    }in desktop, i want the class menu to build the jmenubar for me,
    the i add the jmenubar with the line..setJMenuBar(jMenuBar1);
    both classes compile with no errors, but will not run, stalls on the commandline.
    can anyone see what i'm doing wrong ???
    it's something to do with the second class extending Desktop, and calling that constructor.
    is there a way around my problem ???
    thank you so much
    Paul

    Why don't you try this another way
    public class Desktop extends JFrame implements ActionListener{
             protected JDesktopPane thedesktop;
             private Menu myMenu;
          public Desktop(){
                 super("application");
                  myMenu = new Menu(); //class will build the menubar
                  setJMenuBar(myMenu.getMenuBar() );// call to the method in class Menu that will return a menubar
    public static void main(String args[]){
                Desktop app = new Desktop(); //call constructor
    class Menu extends Desktop{
         JMenuBar menuBar;
    public menu() {
            menuBar = new JMenuBar();
            // and all your stuff here
    public JMenuBar getMenuBar(){
            return menuBar;
    }

  • Dynamically Calling a built-in API Class

    Ok...
    Scenario:
    I'd like to pick between an internal pdf viewer and an external using the java.awt.Desktop class.
    Unfortunately, for development purposes, I need the code to compile on Java 1.5 (1.5 doesn't have java.awt.Desktop)
    Eventually we'll move to 1.6, but until we do, the other contributors don't want to be bothered with commenting out the 1.6 code.
    I figured I could dynamically load the class with:
    Class.forName("java.awt.Desktop")or perhaps
    Class.forName("java.awt.Desktop").newInstance()The Desktop class complains about modifiers "private".
    I tried calling the Desktop.open method directly with:
    Class.forName("java.awt.Desktop").getDeclaredMethod("open", new Class[]{java.io.File.class};).invoke(null, pdfFile);With no luck either.
    I'm compiling on Java 1.6, with the hopes that the 1.5 compilers won't complain. Is this possible, or am I trying to do something outside the scope of Java?
    -FBL

    Hey guys, this WORKS! Infact, the compiled Java 1.5 version flawlessly opens the application with our 1.6 clients!
    I'm pretty impressed that java has this flexibility! Thanks all!
    Here's my exact code. I had to remove a few nulls to supress warnings.
    try {
            desktopCall("open", new File("C:\samplefile.pdf"));
    catch (Exception e) {
            // Open w/ internal viewer
    public static void desktopCall(String call, Object o) throws Exception {
         Class[] f = new Class[]{java.io.File.class};
         Object obj = Class.forName("java.awt.Desktop").getDeclaredMethod("getDesktop").invoke(null);
         Class.forName("java.awt.Desktop").getDeclaredMethod(call,f).invoke(obj,o);
    }-FBL
    Message was edited by:
    FBL

  • Calling Desktop.open() on avi/mp3/wmv/etc (media) files.

    Hello all,
    I am using the Desktop class to open files on the desktop in my signed applet. This is working perfectly for ppt, pps, doc, xls, txt, jpg, pdf files. However, for some reason I am unable to launch any media-type files using this method. I get errors such as "java.io.IOException: Failed to open file:/C:/Users/Bryan/Desktop/4542-sun/Butterfly.wmv. Error message: No application is associated with the specified file for this operation."
    However, there are indeed applications associated with these file types... namely Windows Media Player. Double-Clicking the file directly launches it in WMP as it should. I have been searching around high and low, and can't find much. Note the fact that it is trying to open a URI, starting with file:/. Originally it was just opening the location directly, but I tried using a URI instead to no avail.
    This has happened on 3 separate computers now.
    I have done a work around using Runtime.getRuntime().exec(). However, some of the filenames I am working with can possibly have asian and other UTF-8 characters. That causes a whole new issue, described in http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4947220. I have no idea how to begin using JNI to directly call ShellExecute or if that is even possible from a signed applet standpoint.
    Does anyone have any idea how to fix the issue with Desktop.open() and media files?
    Thanks

    Ok I have searched and searched and found no reliable solution for either of the previous issues. Since this applet is run on a closed intranet, with no fear of malicious intent, I have gone for a different route.
    try {
         desktop.open(new File(fileToOpen.toURI()));
    } catch (Exception e) {
         window.call("launchFile", new Object[] { file.toString() });
    }When the call to Desktop.open() fails, I catch the exception and call a javascript function launchFile(), defined below.
    function launchFile(filename) {
            var o = new ActiveXObject("WScript.Shell");
            o.run(filename);
    }Of course, this limits us to IE ... but it is a necessary evil until Sun fixes the bugs in Desktop.open() and Runtime.exec().
    Hope this helps someone. Again, I still welcome other options.

  • Desktop.open() method doesn't work,

    Hi,
    I'm developing file explorer with JDK6.
    But when I try to open file with native asscociation programs with java.awt.Desktop class, I found that's not work at all.
    there is no response, exception and error. it just 'silent.'
    I checked each line of code. File is exist, Desktop support Open action.
    OS association with file is correct. I couldn't find any problem.
    so I tested tutorial code 'DesktopDemo'. it worked well Browse() but not Open(). open() method isn't work. (It also silent)
    How can I open file with native association?

    Please don't post to threads which are long dead, and don't hijack another poster's thread. When you have a question, start your own thread. Feel free to post a link to a related thread.
    Discussions may be kept on the forum. This is not a place to advertise your blog.
    I'm locking this thread now.
    db
    StijnDeWitt wrote:
    This seems to be a long-running problem related to Desktop.open in combination with Windows and some Account/Profile settings on Windows which are as of yet undetermined.
    Unfortunately the moderators of this forum have the tendency to close/lock old topics so we cannot add new information to a long running problem anymore after a while. They forgot to close this one so luckily I can still add some info here.
    I would like to invite anyone wanting to read details on and discuss this issue to do so on my blog. The comments on that post will never be closed or locked.
    java.awt.Desktop open() fails silently without exception
    (blog link removed)
    >
    You may also want to have a look at these related (but unfortunately locked) forum posts:
    [Desktop.open fails without exception, nothing happens (Locked)|http://forums.sun.com/thread.jspa?threadID=5338022]
    [Desktop.getInstance().open(file) does nothing (nothing happens) (Locked)|http://forums.sun.com/thread.jspa?threadID=5413798]

  • 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

  • 11gR2 Installer - Desktop vs Server option

    Hi all,
    I am installing 11gR2 on SLES 11, and in the installer gui screen, there is Desktop and Server Install type option.
    Can I install server type on desktop pc and vice versa desktop on server machine?
    I am given a HP machine, and i dont know if it is a server or workstation desktop because it looks like server too.
    How can i tell if a machine is a server or a workstation?
    Thanks a lot,
    Yxz

    "If you are installing on a laptop or a desktop, then select the Desktop Class option; otherwise, select the Server Class option to install on a server. These options are available on the System Class screen.
    There is no difference in the software that gets installed after you select any one option but the Desktop Class option installs a single instance database without the advanced configuration options."
    Check
    http://docs.oracle.com/cd/E11882_01/install.112/e16763/whatsnew.htm

  • 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.

Maybe you are looking for

  • Driver for HP psc 2510 and OSX 10.4.10?

    Apple sent an upgrade for my OS 10.4, recommending download, so I did. Subsequently, when I tried to print something from e-mail, a message appeared to the effect that the computer could not recognize the driver. My 2510 HP all in one came up on an a

  • Google Search Timeline function doesn't work in Firefox but does in IE

    I use Google for searches. After receiving search results there are additional options along the left sidebar. The "Timeline" feature takes the search results and sorts them chronologically and display the results on a timeline. This feature used to

  • Database parameter in an ABAP program

    Hi Everyone, Can you tell me if we can set a DB parameter like the one below: ALTER SESSION SET "_B_TREE_BITMAP_PLANS" = FALSE in an ABAP program? if yes then do let me know. Regards, Sugopa

  • SRM 7.0 with WEBDYNPRO PLATFORM

    Hi Experts, The following quesitions are shooted  on Product developers - SRM 7.0 Could any one clarify the follwoing : 1. Is SRM 7.0 is on webdynpro platform, if so, No ITS isavailable with SRM 7.0. 2. Is SICF is available for activating services in

  • Audio file "Bass#14.aif" not found!

    Hey Logicians- I've misplaced my root audio files. I've tried using this phrase (Audio file "Bass#14.aif" not found!) and several derivatives thereof in the finder while highlighting my hard drive (complete search right?), but found nothing...same de