JNLP FileOpenService vs JFileChooser getPath()

In my Web Start application, I'm trying to browse a directory and remeber the path to specific folders/files. I've managed to perform all the security coding to read in files with FileOpenService, but I've read that there is no way to actually remeber the location on the host computer where that file came from.
I would eventually like to use the mkdir() function in a selected directory and I don't want my users to have to manually select a "home" directory every time. Is there any way to get around this like JFileChooser's .getPath() function?
Thanks Much,
Daniel

It should be easy enough to write a small abstract class or interface with two concrete implementations, one for each environment, so that the rest of your program doesn't care which is in use.

Similar Messages

  • JNLP FileOpenService warning despite signed applet w/ "all-permissions"

    Hi all,
    We are deploying an applet using java 7u21. The applet is signed and the jnlp file contains a security section requesting "all-permissions". Even so, every time that we run the applet a pop-up appears with "The application has requested read/write access to a file on the machine. [...]"
    My understanding is that this warning should no longer display... Is that true? The only thing I have found related to this is http://docs.oracle.com/javase/7/docs/technotes/guides/javaws/developersguide/faq.html#s407, but that seems to indicate I should only see this dialog if I lack file access permissions. (I think I have those via trusted cert + jnlp all-permissions setting).
    Thanks for the help,
    Buzzy
    Relevant text from the link:
    5074526: ExtenededService file APIs show security dialog even if app is signed.
    In version 1.5.0.
    When using the FileOpen Service, the security dialog will only show if the application does not
    have file access permissions. This is not true with the new ExtendedService OpenFile, and
    OpenFiles methods, the security dialog shows anyway.

    I am having the same problem. We are using JRE 1.4.1_05. When a certain EJB is called I get:
    java.security.AccessControlException: access denied (java.net.SocketPermission XXX.XX.XX.XXX:7001, connect,resolve)
    at java.security.AccessControlContext.checkPermission (Unknown Source)...
    I have tried setting the following permission in my jre's /lib/security/java.policy file:
    grant{
    permission java.net.SocketPermission "host:port", "accept,connect";
    After setting this permission the EJB that caused this error seems to crash. Is this the correct permission to set for the above mentioned exception? Is there any other alternative to uninstalling the security manager?

  • Problems with cursor and shortcuts when using JNLP services on MAC OS X

    After invoking the JNLP services on a MAC I loose the ability to set the cursor and invoke keyboard shortcuts. On Windows this is not a problem, so I believe it is a bug and I have reported it to Apple. Meanwhile, I would appreciate if someone could help me with finding a work-around. To identify the problem run the following code with Java Web Start (i.e., you need to add the program to a jar and launch it using a JNLP script). You also need to include the javax.jnlp package.
    Observe that the cursor changes to cross-hairs when entering the circle. After invoking the Open file menu item, the cursor does not change any longer. Shortcut key do not work either, but if you open the menu and close it again without selecting any of the menu items, the shortcuts are OK again.
    package bugreport;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.IOException;
    import javax.swing.*;
    import javax.jnlp.*;
    public class Demo2 extends JPanel implements Runnable, MouseMotionListener {
        private int centerX = 100;
        private int centerY = 100;
        private int radius = 50;
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Demo2());
        public void run() {
            int menuMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
            final JFrame frame = new JFrame("Bug Demo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setPreferredSize(new Dimension(200, 200));
            addMouseMotionListener(this);
            JMenuBar menuBar = new JMenuBar();
            frame.setJMenuBar(menuBar);
            //File menu
            JMenu fileMenu = new JMenu("File");
            fileMenu.setMnemonic('F');
            menuBar.add(fileMenu);
            //openMenuItem
            JMenuItem openMenuItem = new JMenuItem("Open...");
            openMenuItem.setMnemonic('O');
            openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, menuMask));
            openMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    openFile();
            fileMenu.add(openMenuItem);
            frame.add(this);
            frame.pack();
            frame.setResizable(false);
            frame.setVisible(true);
        @Override
        public void paintComponent(Graphics g) {
            g.clearRect(0, 0, getWidth(), getHeight());
            g.setColor(Color.BLUE);
            g.fillOval(centerX - radius, centerY - radius, 2 * radius, 2 * radius);
        public void mouseDragged(MouseEvent e) {
        public void mouseMoved(MouseEvent e) {
            int dx = e.getX() - centerX;
            int dy = e.getY() - centerY;
            if (dx * dx + dy * dy < radius * radius) {
                setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
            } else {
                setCursor(Cursor.getDefaultCursor());
        private void openFile() {
            FileOpenService fos = null;
            try {
                fos = (FileOpenService) ServiceManager.lookup("javax.jnlp.FileOpenService");
            } catch (UnavailableServiceException ex) {
                JOptionPane.showMessageDialog(this, "Service unavailable", "Open", JOptionPane.ERROR_MESSAGE);
            if (fos != null) {
                try {
                    FileContents fc = fos.openFileDialog(null, null);
                } catch (IOException ex) {
                    JOptionPane.showMessageDialog(this, "Service unavailable", "Open", JOptionPane.ERROR_MESSAGE);
    }Edited by: James_Vagabond on Oct 29, 2009 9:35 AM

    Barbara, Thanks very much taking the time to respond to my posting. Your input and directions were just what I needed.I accessed the print settings in the pull down menu, setup the print options including the color profile for Elements and the Printer to sRGB, and printed my picture. This resolved all the invalid color problems I was having, but I did notice that there was a hint of magenta overall in the picture. I had read an article that said to use Canon Color Matching instead of Color Sync to prevent that but I couldn't make that change in the pull down menu. I tried in the Presets dialog box but that didn't appear to be possible. Should I make that change as well?
    Also, in my travels through Elements 13 I notice under Edit->Color Settings that there were options for No Color Mgmt, Optimize for Screen, for Printing, or ability to chose one or the other (real time I assume). How do those options fit into this scenario?
    Thanks again

  • Where do you get jnlp.jar for Mac Leopard 10.5.5

    Hello,
    I am trying to use Persistence in JNLP on a Mac 10.5.5 with either 1.5 or 1.6. I have searched
    my local disk the Mac developer web site and this website for "jnlp java Mac Leopard" no useful results.
    Where can I get a jnlp.jar file that works on a Mac?
    Rinaldo

    I was able to get the question answered on the mailto:[email protected] list.
    My friend http://www.google.com/search?q=jnlp.jar+mac+java&ie=utf-8&oe=utf-8&aq=t answered it.
    Greg also provided some very useful information, especially the mdfind javaws.jar command
    http://lists.apple.com/archives/Java-dev/2008/Nov/msg00052.html
    I see that in JDK 1.5, javaws.jar is included. For now I will assume that the javaws.jar classes have been moved to javaws.jar
    jar tvf ./Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/javaws.jar | grep jnlp
            0 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/
      3147 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/ApiDialog.class
      1626 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/AppletAudioClip$1.class
      3922 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/AppletAudioClip.class
      1377 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/AppletContainer$1.class
       990 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/AppletContainer$2.class
      1329 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/AppletContainer$AppletContainerContext$1$1.class
      1452 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/AppletContainer$AppletContainerContext$1.class
      2942 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/AppletContainer$AppletContainerContext.class
      1551 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/AppletContainer$AppletContainerStub.class
       710 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/AppletContainer$LoadImageAction.class
      4841 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/AppletContainer.class
       234 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/AppletContainerCallback.class
      1362 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/BasicServiceImpl$1.class
      1158 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/BasicServiceImpl$2.class
       992 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/BasicServiceImpl$BasicServiceBrowser.class
      2397 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/BasicServiceImpl.class
      1279 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/CheckServicePermission.class
       868 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/ClipboardServiceImpl$1.class
      1668 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/ClipboardServiceImpl$2.class
      2787 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/ClipboardServiceImpl.class
      1159 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/DownloadServiceImpl$1.class
      1652 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/DownloadServiceImpl$10.class
      1318 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/DownloadServiceImpl$2.class
      1474 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/DownloadServiceImpl$3.class
      1679 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/DownloadServiceImpl$4.class
      2519 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/DownloadServiceImpl$5.class
      1739 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/DownloadServiceImpl$6.class
      1942 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/DownloadServiceImpl$7.class
      1517 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/DownloadServiceImpl$8.class
      1445 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/DownloadServiceImpl$9.class
      1398 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/DownloadServiceImpl$DefaultProgressImpl$1.class
      2914 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/DownloadServiceImpl$DefaultProgressImpl.class
      2254 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/DownloadServiceImpl$ProgressHelper.class
      8288 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/DownloadServiceImpl.class
       900 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/ExtendedServiceImpl$1.class
      1051 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/ExtendedServiceImpl$2.class
      3188 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/ExtendedServiceImpl.class
       707 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/ExtensionInstallerServiceImpl$1.class
       961 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/ExtensionInstallerServiceImpl$2.class
       711 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/ExtensionInstallerServiceImpl$3.class
      5918 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/ExtensionInstallerServiceImpl.class
       787 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/FileContentsImpl$1.class
       820 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/FileContentsImpl$2.class
       928 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/FileContentsImpl$3.class
       791 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/FileContentsImpl$4.class
       792 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/FileContentsImpl$5.class
      1002 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/FileContentsImpl$6.class
      4353 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/FileContentsImpl.class
      2155 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/FileOpenServiceImpl$1.class
      2323 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/FileOpenServiceImpl$2.class
      1144 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/FileOpenServiceImpl$WindowsAltFileSystemView$FileSystemRoot.class
      3017 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/FileOpenServiceImpl$WindowsAltFileSystemView.class
      2974 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/FileOpenServiceImpl.class
      2847 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/FileSaveServiceImpl$1.class
      3257 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/FileSaveServiceImpl.class
      1087 Fri Sep 05 10:32:48 EDT 2008 com/sun/jnlp/ImageCache.class
      1937 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/JNLPCachedJarURLConnection$1.class
      5559 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/JNLPCachedJarURLConnection.class
       940 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/JNLPClassLoader$1.class
       928 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/JNLPClassLoader$2.class
      1285 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/JNLPClassLoader$3.class
    12413 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/JNLPClassLoader.class
      2555 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/JNLPFileFilter.class
      6074 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/JNLPRandomAccessFileImpl.class
       788 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/JnlpLookupStub$1.class
      2918 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/JnlpLookupStub.class
      2044 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/MeteredFileOutputStream.class
       938 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PersistenceServiceImpl$1.class
      1022 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PersistenceServiceImpl$10.class
      1805 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PersistenceServiceImpl$11.class
      1023 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PersistenceServiceImpl$2.class
       845 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PersistenceServiceImpl$3.class
       877 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PersistenceServiceImpl$4.class
       981 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PersistenceServiceImpl$5.class
       875 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PersistenceServiceImpl$6.class
       871 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PersistenceServiceImpl$7.class
       885 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PersistenceServiceImpl$8.class
       974 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PersistenceServiceImpl$9.class
      7991 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PersistenceServiceImpl.class
       809 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PrintServiceImpl$1.class
      1189 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PrintServiceImpl$2.class
       969 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PrintServiceImpl$3$1.class
      1717 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PrintServiceImpl$3.class
      2986 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/PrintServiceImpl.class
      1441 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/SingleInstanceServiceImpl$1.class
      1673 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/SingleInstanceServiceImpl$TransferListener.class
      3938 Fri Sep 05 10:32:50 EDT 2008 com/sun/jnlp/SingleInstanceServiceImpl.class
         0 Fri Sep 05 10:32:48 EDT 2008 javax/jnlp/
       258 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/BasicService.class
       251 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/ClipboardService.class
      1392 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/DownloadService.class
       349 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/DownloadServiceListener.class
       309 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/ExtendedService.class
       659 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/ExtensionInstallerService.class
       598 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/FileContents.class
       370 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/FileOpenService.class
       430 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/FileSaveService.class
      1451 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/JNLPRandomAccessFile.class
       688 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/PersistenceService.class
       350 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/PrintService.class
       994 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/ServiceManager.class
       303 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/ServiceManagerStub.class
       185 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/SingleInstanceListener.class
       250 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/SingleInstanceService.class
       472 Fri Sep 05 10:32:50 EDT 2008 javax/jnlp/UnavailableServiceException.class

  • JDeveloper and jnlp.jar or javaws.jar

    Hi, I am developing an applet with the JDeveloper 12c, I am using the JSDK 1.7.
    While implementing the java program I need to use FileOpenService or FileContent classes for that I need to import javax.jnlp.*
    But is not included in the 1.7 JDK,
    My sorce code is like this:
            try {
                FileOpenService fileOpenService = (FileOpenService) ServiceManager.lookup("javax.jnlp.FileOpenService");
                FileContents contents = fileOpenService.openFileDialog(null,null);
    Do you know how can I import this classes at this environment??.
    Thank you in advance.

    what do stacktrace mean??????? Please do not hold down you '?' key.
    One question mark is enough.
    Here is a simple example of a stacktrace..
    If you run this code..public class ShowStackTrace {
      public static void main(String[] args) {
        Object object1 = new Object();
        System.out.println( object1.getClass() );
        Object object2 = null;
        System.out.println( object2.getClass() );
    }It writes this to the console..class java.lang.Object
    Exception in thread "main" java.lang.NullPointerException
            at ShowStackTrace.main(ShowStackTrace.java:6)
    Press any key to continue . . .The first line is program ouput.
    The 2nd & 3rd lines are a stacktrace.
    The stacktrace tells us exactly which line
    of the program failed (line 6), and what
    went wrong (NullPointerException).
    Both Java applets and Java Web-Start
    applications can have a console appear.
    The console will show any stacktraces
    that happen in the code (or it should), and
    you need to find how to open the
    web-start console, on your PC.
    What OS and Java (version) are
    you running?
    And another thing. Please do not
    ignore me. Twice I have asked you
    to post your JNLP file, yet twice you
    have not done so, and not made any
    comment.
    Feel free to ask questions about
    anything I write that is not clear,
    but be warned I will not ask again*,
    for you to show us the JNLP file.
    * Instead, I will just just stop repeating
    myself, and stop trying to help you.

  • Suggest a filename extension in a save file dialog

    Hello guys,
    does any of you know, how to suggest the user a certain filename extension in a save file dialog?
    I'm using both the normal save file dialog:
         javax.swing.JFileChooser.showSaveDialog,
    and the Java Web Start save file dialog:
         javax.jnlp.FileSaveService.saveFileDialog.
    For both ways I seem not to be able to suggest the user a certain extension for the filename.
    For the normal dialog, I call setFileFilter on the JFileChooser instance.
    The filter shows up in the dialog, and is used by default, but when the user types a name and approves, the returned filename does not have the extension added.
    Of course I can add the extension programmaticaly, but not when inside the JAWS sandbox.
    For the JAWS dialog, I pass an array containing my extension, but it is ignored as if I didn't specify any extensions. The API specs already say that this parameter "might be ignored by the JNLP Client".
    So how to tell the user what extension to use?
    More people must have encountered this problem.
    I'm making an application that saves and opens xml files and exports html files.
    I'm using this code to test the behavior:import java.io.ByteArrayInputStream;
    import java.io.File;
    import javax.jnlp.FileContents;
    import javax.jnlp.FileSaveService;
    import javax.jnlp.ServiceManager;
    import javax.jnlp.UnavailableServiceException;
    import javax.swing.JFileChooser;
    import javax.swing.filechooser.FileFilter;
    public class ChooseFile
        static final String[] EXTENSIONS = { "xml" };
        static final String DESCRIPTION = "XML files";
        public static void main(String[] args)
         try {
             ServiceManager.lookup("javax.jnlp.FileOpenService");
             // we're running with JAWS
             System.out.println("JAWS filechooser:");
             System.out.println(choose_JAWS());
         catch (UnavailableServiceException x)
             // we're NOT running with JAWS
             System.out.println("normal filechooser:");
             System.out.println(choose_normal());
        static String choose_normal()
         JFileChooser fc = new JFileChooser();
         fc.setFileFilter(new CustomFileFilter(EXTENSIONS, DESCRIPTION));
         if (JFileChooser.APPROVE_OPTION == fc.showSaveDialog(null))
             return "selected " + fc.getSelectedFile().getName();
         else
             return "cancelled";
        static String choose_JAWS()
         try {
             FileSaveService fos = (FileSaveService)ServiceManager.lookup(
                         "javax.jnlp.FileSaveService");
             ByteArrayInputStream stream = new ByteArrayInputStream(new byte[] {});
             FileContents fc = fos.saveFileDialog(null, EXTENSIONS, stream, null);
             if (fc != null)
              return "selected " + fc.getName();
             else
              return "cancelled";
         } catch (Exception x)
             x.printStackTrace();
            return "";
    class CustomFileFilter extends FileFilter
        String[] extensions;
        String description;
        public CustomFileFilter(String[] extensions, String description)
         this.extensions = extensions;
         this.description = description;
        public boolean accept(File f)
         if (f.isDirectory())
             return true;
         String extension = getExtension(f);
            if (extension == null)
                return false;
         for (int i=extensions.length; i-->0; )
             if (extension.equals(extensions))
              return true;
         return false;
    public String getDescription()
         return description;
    private String getExtension(File f)
    String ext = null;
    String s = f.getName();
    int i = s.lastIndexOf('.');
    if (i > 0 && i < s.length() - 1)
    ext = s.substring(i+1).toLowerCase();
    return ext;
    }Any help is greatly appreciated!
    Tom Jansen

    @tjacobs01
    Hi Tom,
    I have a question regarding your classes
    tjacobs.ui.fc.FileExtensionFilter and
    tjacobs.ui.fc.FileChooser.
    When I look at your code, I see the filename extension is appended in showSaveDialog:     public int showSaveDialog(Component c) {
                        setSelectedFile(new File(f.getAbsolutePath() + "." + ((FileExtensionFilter)filter).getType()));
        }It gets the extension by calling getType on the filter. But getType is implemented as:    public String getType () {
            return mExtensionList.get(0).toString();
        }So this returns the first type in the list. It does not check what filetype is selected by the combobox.
    Am I missing something?
    Also, in getDescription:    public String getDescription() {
            if (mDesc == null) {
                mDesc = "";
                for (int i = 0; i < mExtensionList.size(); i++) {
                    mDesc += (i != 0 ? ", " : "") + "." + mExtensionList.get(0).toString();
                mDesc+= " files";
            return mDesc;
        }you seem to iterate through the list, but only take the first entry every iteration.
    Can you explain mExtensionList.get(0)?
    Do you know how to test what type is selected in the JFileChooser's combobox?

  • Instead of using the make file can you build nirlpk.sys using MS WDK 8.0 on VS2012?

    After downloading the NI nimhddk_windowsWDM-2 and -1
    Instead of using the make file I built nirlpk.sys using MS WDK 8.0 on VS2012
    I copied the source files out of the dir /nirlpk to the MS template for WDM drivers
    It built after turning warnings as errors off.
    After uninstalling the NI_DMX driver I tried to install the RLP driver that consisted of nirlp.inf and nirlpk.sys
    I got this message:
    Windows found driver software for your device but encounted and error while attempting to install it.
    PCI-6602 RLP WDM
    Driver is not intended for this platform
    Is the nirlp.inf file correct for loading on Windows 7 64 bit?
    Any ideas?

    I have now altered the example along lines
    suggested by ghaneman*, who pointed out that
    a trusted application did not need to use the
    FileOpenService/FileContents just to get an
    InputStream.
    * Mentioned on 'File associations / sandboxed app.'
    http://forum.java.sun.com/thread.jspa?threadID=785224
    The altered code is..
    /** Load a file into the editing area.
    @param path A string representing the path to the desired file. */
    public void loadFile(String path) {
        // first try as if this were a trusted application..
        if (!path.equals(".")) {
            try {
                FileInputStream inputStream = new
                    FileInputStream(path);
                loadFile(inputStream);
            } catch (Exception e) {
                // we do not have trust, use the FileOpenService
                loadFileByFileService(path);
        } else {
            // we only have a directory, use the FileOpenService
            loadFileByFileService(path);
    public void loadFileByFileService(String path) {
        try {
            if (fileOpenService==null) {
                fileOpenService = (FileOpenService)ServiceManager.
                    lookup("javax.jnlp.FileOpenService");
            fileContents = fileOpenService.openFileDialog(path, xtns);
            // the user may have cancelled the action..
            if (fileContents!=null) {
                loadFile( fileContents.getInputStream() );
        } catch(UnavailableServiceException use) {
            use.printStackTrace();
        } catch(IOException ioe) {
            ioe.printStackTrace();
    }If the user launches the trusted version, and
    selects 'always trust' for the (self signed)
    certificate, the end user can thereafter double
    click a file and see it appear in the application's
    editing area with no further user interaction.

  • I can't open or save file with Java Web Start

    Hi,
    i can't open or save file with Java Web Start:
    import java.io.*;
    import java.util.*;
    public class MetaDataFileCreator {
    public String fileNameSpace = null;
    public String fileName = null;
    protected Properties file = null;
    public MetaDataFileCreator(String fileNameSpace, String fileName) {
    this.fileNameSpace = fileNameSpace;
    this.fileName = fileName;
    public void createMetaDataFile() {
    try {
    System.out.println("file METADATA");
    ClassLoader cl = this.getClass().getClassLoader();
    String nameFileMetaData = fileNameSpace + fileName + ".txt";
    FileOutputStream fileOS = new FileOutputStream(cl.getResource(nameFileMetaData).getFile());
    file = new Properties();
    file.setProperty("aaaaa", "aaaa");
    file.store(fileOS, "");
    fileOS.close();
    } catch (Exception e) {
    System.out.println("Error writing metadata-file: " + e);
    System.exit(1);
    e.printStackTrace();
    I have try also to open a file like this:
    ClassLoader cl = this.getClass().getClassLoader();
    file.load(cl.getResourceAsStream(nameFile));
    also like this:
    try {
    fos = (FileOpenService)ServiceManager.lookup("javax.jnlp.FileOpenService");
    fss = (FileSaveService)ServiceManager.lookup("javax.jnlp.FileSaveService");
    } catch (UnavailableServiceException e) {
    fss = null;
    fos = null;
    System.out.println("Error with JNLP");
    System.exit(1);
    if (fss != null && fos != null) {
    try {
    // get a FileContents object to work with from the
    // FileOpenService
    FileContents fc = fos.openFileDialog(null, null);
    //FileContents newfc2 = fss.saveAsFileDialog(null, null, fc);
    // get the OutputStream and write the file back out
    if (fc.canWrite()) {
    // don't append
    os = fc.getOutputStream(false);
    } catch (Exception e) {
    e.printStackTrace();
    also like this:
    File f = new File((System.getProperty("user.home")+"x.txt").toString());
    FileOutputStream fileX = new FileOutputStream(f);
    OutputX = new PrintWriter(new BufferedWriter(new OutputStreamWriter(fileX, "UTF8")));
    OutputX.println(....
    but it doesn't work with Java Web Start.
    Can someone help me?
    How can I open or save file?
    thank you.
    Sebastiano

    Did you specify <all-permissions/> in your JNLP file? Did you sign your code? What error are you getting?

  • Creating a FileContents breaks setTooltipText if a html string is passed

    static void ThisAlsoWorks(){
    try {
    String message = "<html><body>This is my serialized object</body></html>";
    MyToolTipTest2 toolTipTest = new MyToolTipTest2(message);
    Thread.sleep(5000L);
    FileOpenService fos = (FileOpenService)ServiceManager.lookup("javax.jnlp.FileOpenService");
    FileContents fileContents = fos.openFileDialog(null, null);
    MyToolTipTest2 toolTipTest2 = new MyToolTipTest2(message);
    } catch (Exception ex) {
    ex.printStackTrace();
    If you mousehover the first frame before the thread.sleep ends, the tooltip shows up, the filechooser pops up, you choose a random file since it won't do anything with it, the new frame pops up, and both have their html tooltips working. However, if you relaunch it and you do not mousehover the first frame to see the tooltip before the sleep ends and the filechooser pops up, the tooltips won't ever show up anymore on either frame.
    Here is a video of the issue: http://www.youtube.com/watch?v=bpuFB_RmuMQ

    user9177879 wrote:
    Thank you,.. You're welcome.
    ..following that link's workaround of adding ParserDelegator workaround = new ParserDelegator(); before using the FileContents did solve the issue somehow.Glad it worked for you. I have projects that use HTML in labels and need to revisit them to implement that workaround, though I'm busy on other matters at the moment.
    BTW - when posting code or 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.

  • BufferedReader problems

    Hello all.
    I'm trying to use a BufferedReader to read in data from a file that is in a Jar. Locally of course it works but or WebStart I get java.Security.AccessControlException which leads me to believe that it is trying to read a local file and since my program is not signed, it fails. The jars will not be signed since there is no need for it given that all files will be contained withing the same jar (called: files.jar). I know that I can access this jar because I am getting all sorts of Images from it over Java WebStart. Here is my code:
         public Vector<String []> readFiletoVectorOfArrays (String delimeter, String path){
    ///unrelated code
                   System.out.println ("readFileToVectorOfArrays().path: " + path);
                   InputStream instream = getClass().getResourceAsStream(path);
                   System.out.println ("instream.toString() = " +instream.toString());
                   InputStreamReader infile = new InputStreamReader(instream);
                   System.out.println ("infile.toString = " +infile.toString());
                   BufferedReader inbuf = new BufferedReader(infile);
    // unrelated code
    }Any help is greatly appreciated.

    >
    nevermind, found the bug. >Glad you sorted it. Thanks for having the sense to report the solution back to the forum.
    >
    ..it was somewhere else completely involving JFileChoosers which of course do not work over JNLP. ...>Sure they do, as your comment above about the jars not being signed indicates you already understand. JFileChoosers work just fine for a signed app. that requests extended permissions.
    OTOH, local files can be accessed for either reading or writing even in sandboxed web start applications by using the JNLP API's FileOpenService* or FileSaveService. I had some examples up at my site, but it is offline for the moment.
    * <http://java.sun.com/j2se/1.5.0/docs/guide/javaws/jnlp/javax/jnlp/FileOpenService.html>
    An aside. I had a look at this post as soon as it first showed up. It looked to me there could be no way that code could fail in the way described, but without a complete example I did not feel confident enough to make comment.
    If you can provide an example off your server, or even a post a 'complete' example of code and JNLP file that fails for other people as it does for you - that can often speed the resolution process. I am such a fan of the complete example that I wrote an article on it, which is fortunately mirrored a number of places besides my site. Here is one mirror.. <http://homepage1.nifty.com/algafield/sscce.html>
    In this case, the process of preparing an SSCCE would hopefully have revealed the actual source of the error (by a simple process of eliminating unnecessary code).

  • FileSaveService problem

    For some reason for which i cannot understand, i used to be able to do this....
    FileSaveService fss = (FileSaveService)ServiceManager.lookup("javax.jnlp.FileSaveService");
    FileContents fc = fss.saveFileDialog("c:\\", null, null, null);I could then write to the file at my leisure throught the FileContents class rather then pass a stream to the saveFileDialog method to write out. Passing null would just create the file ready to output data but not write anything to the file.
    However, recently i recompiled and now when i run it i get a Closed Stream io error.
    My current workaround is to use...
    FileOpenService foc = (FileOpenService)ServiceManager.lookup("javax.jnlp.FileOpenService");
    FileContents fc = foc.openFileDialog(null, null); and then i can write to the FileContents as i desire, however, the draw back is that the user has to select a file to save to from a file dialogue title "Open File..."
    Any ideas ?
    Thanks guys
    Alistair

    stream closed error has been recently caused by a bug in java.net.
    What version of java is being used ? If it was a beta of 1.5.0, updating to the latest drop will fix it.
    /Dietz

  • Jfilechooser vs jnlp

    The tutorial on jfilechooser says that for a webstart app one should use the jnlp api instead of jfilechooser, but they don't say why...if I am writing a program intended to be a fat client that has access to files on the user's machine, which should I use?
    Thanx

    Stop crossposting. This Angela already posted that stuff in here, and I already visited your thread in the JNLP forum.

  • JFileChooser  and JNLP

    I am trying to use this code to be able to open a file:
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/FileChooserDemo.java
    When I run it with NetBeans, it works...
    But when I try to run my .jnlp file nothing happens....
    I've been trying to figure out how to get JFileChooser to work with JNLP and I am not getting anywhere. Any advice?

    Stop crossposting. This Angela already posted that stuff in here, and I already visited your thread in the JNLP forum.

  • JFileChooser and security

    Has anybody got the JFileChooser to open the user.dir or user.home directory? [I have used JFileChooser(".")] I have used the policytool to generate a policy file and also have tried to follow Irene's 10 steps to signing an applet but non have worked. I keep getting the security exception thrown that access denied to user.home or user.dir. Does anybody have an example policy file and a snippet of the JFileChooser code they used to open the local file system without getting a security exception throw? Any help would be much appreciated!
    Thank you in advance,
    dave

    The Notpad demo uses the JNLP api to read and write files. The api doc can be found at:
    http://java.sun.com/products/javawebstart/docs/javadoc/index.html
    Although the Notpad demo source is not available, there is other sample code available at:
    http://developer.java.sun.com/developer/releases/javawebstart/
    Included here is the webpad demo, which uses the FileOpenService and
    FileSaveService API's.

  • Why JFileChooser doesn´t show when using JWS?

    I have this code where a JFileChooser is shown and the user must choose a directory where JasperReport must be exported to Excel.
    Everything works fine when running locally (the jar file) but when I put in the server and my client runs it using JWS the JFileChooser dialog doesnt show up.
    I am aware that the JNLP must have all-permissions, and it is but still does not show the diago to select the directory. And worse, no exceptions are shown else well.
    final JFileChooser fc = new JFileChooser();
    int choice = 0;
    try {
         fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
         System.out.println("1"); // DOES NOT REACH THIS LINE
         fc.setDialogTitle("Select Directory to Export");
         System.out.println("2");
         fc.setApproveButtonText("Select");
         System.out.println("3");
         fc.setMultiSelectionEnabled(false);
         System.out.println("4");
         fc.setCurrentDirectory(new File("C:/Kooky/SigGraf"));
         System.out.println("5");
         choice = fc.showOpenDialog(frame);
         System.out.println("6");
    } catch (Exception ex) {
         ex.printStackTrace();
    if (choice == JFileChooser.APPROVE_OPTION) {
         Thread worker = new Thread() {
              @Override
              public void run() {
                   String msg = "";
                   try {
                        File dir = fc.getSelectedFile();
                        String local = dir.getPath();
                        msg = Report.exportarParaExcel(startDate, endDate, local);
                   } catch (Exception ex) {
                        ex.printStackTrace();
                   final String msg2 = msg;
                   SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                             JOptionPane.showMessageDialog(frame, msg2);
         worker.start();
    } else {
         JOptionPane.showMessageDialog(frame, "You did not select a directory to export the report.");
    }The JNLP file:
         <security>
              <all-permissions/>
         </security>
    All the jars are signed with the same certificate.

    FranzAnthony wrote:
    Amazing your answer, you asked for exactly what I posted, thanks a lot for your help, let it be.Please read the SSCCE link again, as it isn't "exactly" what you posted. It's so much easier to answer questions when a nice compilable and runnable example has been provided by the OP. You are not required to do this of course, but if you do provide one, the odds of getting a quick helpful answer will be greatly increased.
    Or you can post a snarky comment and antagonize all the rest of the forum regulars who otherwise would have helped you. Your call.

Maybe you are looking for

  • Browse Data & Parameter flds no longer fully populated after upgd  SQL 2005

    I upgrade our SQL 2000 Server last weekend to SQL 2005 (sp2). Now our Crystal reports that access SQL data are not working correctly. Parameter Fields are showing little to no data, where before the upgrade we were seeing many more rows in the list.

  • Insufficient free space in the database during upgrademodule General checks

    we are upgrading SAP R/3 Enterprise 470 110 to ECC6 on Oracle/Windows. During PREPARE module: General checks the file CHECKS.LOG show the following information:    #====================================================# Requests and information for mo

  • THANK YOU TO VERIZON

    I would like to take this opportunity as one of the more vocal critics of Verizon for their delay in updates, to thank you for delivering us the Lumia Denim firmware update for the Lumia Icon before any other U.S. Carrier did.  I know that getting up

  • QM_LSMW for Inspection plan by BAPI method

    Hi All, Does anybody has any idea about LSMW by business object method using business object BUS1191? can anybody give step by step procedure for the same? Best Regards, Anand Rao

  • *XDIM_GETMEMBERSET returning no results

    Hello experts, I am attempting to use an *XDIM_GETMEMBERSET statement so that my script logic will only run on Time periods in which a statistical account has been populated with a value of 1. The code I have written is as follows: *XDIM_GETMEMBERSET