locked
standalone *.jar will not throw exceptions RRS feed

  • Question


  • Hello,
    I have an app that runs good in the NETBEANS ide.  When I run it as a stanalone exec.jar and place the executable in the project folder or when I place the executable on the thumb drive it runs with anomolies. 
    When I run the app from a thumb drive  it will not throw my exceptions
    I am using Netbeans ide.
    It will create the frame.ser and save it in my dir and it will write my XML properly but it will not do both. If it actually writes my XML it will stop before it adds the default close operation "X" in the upper right corner.
    When running  the app from the thumb drive it does not complete the JInternalFrame and it reads the frame.ser yet it will not open. I must be encountering a loadXMLResource problem.

    What is it about a standalone exec .jar  using dependencies that does not want to properly serialize a JInternalFrame  to a dir on the thumb drive and open it?
    My app is using the variable:
    [code]

    public static final String USERDIRDIR = System.getProperty("user.dir", ".");

    [/code]
    and the XML.xml  file is in the userdir at:
    [code]

    public static final String XMLRESOURCES = "xml/ModelResourcesXML.xml";

    [/code]

    I also use a properties sheet

    [code]
    public static final String RESOURCES = ModelUtils.class.getPackage().getName()
                + ".resources.ModelResources";
    [/code]

    As I mentioned. When I run the app as a standalone on the thumb drive. It will not throw any of my exceptions: exeception example to follow.

    thanks
    [code]

    public SerializeFrame() throws FileNotFoundException, ProfileException, LoginException, SQLException, javax.security.auth.login.LoginException, ClassNotFoundException, InstantiationException, IllegalAccessException {

            String M = (" --> in  public SerializeFrame() var: xxxxxxxxx : xxxxxxxx<-- \n");
            System.out.println(M);


        }

        public static boolean doSerialize(JInternalFrame frame) throws ProfileException, model.err.LoginException, FileNotFoundException, IOException, NoTargetFoldersException, SQLException, LoginException, SuccessfullTargetFoldersCreation, PropertyVetoException {

            String M = (" --> public void doSerialize(" + frame.getTitle() + ") var: (JInternalFrame frame) :<-- \n");
            System.out.println(M);

            GuideSystems.GuideSystemsJDesktopManager.setCurrentFrame(frame);
            String action = "meta";


            bSaved = true;
            String systemDir = LoginInfo.getSystemFolderSystemDir() + File.separator + frame.getTitle() + EXT;


            NotesFrameAttrToXML nfat = new NotesFrameAttrToXML();
            nfat.sysOut(frame, action);

            FileOutputStream fo = new FileOutputStream(systemDir);
            ObjectOutputStream oo = new ObjectOutputStream(fo);

            oo.writeObject(frame);
            oo.flush();
            oo.close();

     

            //bSaved = discoverSystemFolderSourceDir();
            return bSaved;
        }

      

    [/code]


    [code]

    package model.err;

    import java.io.FileNotFoundException;
    import java.io.IOException;

    public class LoginException extends ModelException {
        public LoginException() throws FileNotFoundException, IOException {
            super("LoginException");
            System.out.println("JOptionPane delivered error message \n " +
                    "Login failed Please contact the Webmaster." );
        }

    }

     

     

    [/code]


    [code]

    package model.err;

    import java.io.FileNotFoundException;
    import java.io.IOException;
    import model.ModelUtils;


    public class ModelException extends Exception {
        public ModelException(String messageKey) throws FileNotFoundException, IOException {
            super(ModelUtils.getXMLResource(messageKey));
        }
    }


    [/code]


    ModelResourcesXML.xml


    [code]

    <entry key="LoginException"> Login failed.
        Please contact the Webmaster.
        </entry>
        <entry key="UserNameException"> Please enter a user name. </entry>
        <entry key="PasswordMismatchException"> Retype passwords to match! </entry>
        <entry key="PasswordMismatchInstructorException"> Retype Instructor passwords to match! </entry>
        <entry key="PasswordMismatchStudentException"> Retype Student passwords to match! </entry>
     <entry key="UserAssetsNoDeleteException"> Some user assets could not be deleted </entry>

    [/code]


    [code]
     public static synchronized ResourceBundle getResources() throws FileNotFoundException, IOException {

     

            if (resources == null) {
                try {
                    resources = ResourceBundle.getBundle(RESOURCES);
                } catch (MissingResourceException x) {
                    log(x);
                    throw new InternalError(x.getMessage());
                }
            }

            return resources;
        }

        public static String getResource(String key) throws FileNotFoundException, IOException {
            System.out.println("useing getResource for instance: " + key);
            return getResources().getString(key);
        }

        public static synchronized Properties loadXMLResources() throws IOException {
            FileInputStream fis = new FileInputStream(XMLRESOURCES);
            xmlResource = new Properties();
            xmlResource.loadFromXML(fis);

            /*
            Enumeration enuKeys = xmlResource.keys();
            while (enuKeys.hasMoreElements()) {
            String key = (String) enuKeys.nextElement();
            String value = xmlResource.getProperty(key);
            System.out.println(key + ": " + value);
            }
             *
             */


            fis.close();
            return xmlResource;
        }

        public static synchronized String getXMLResource(String key) throws FileNotFoundException, IOException {
            return loadXMLResources().getProperty(key);
        }

     

    [/code]

    Hello again.

    I have another app that I am having the same problem with. This one has the apache dery imbedded database. Along with no exceptions the app creates my db folder but it does not know how to put the necessary db in the created dir. It to is loading xml to use properties. Netbeans has the derby.jar
    file added in the library

    [code]

    C:\Users\Steves\Documents\ceyesumma\java_cache\my_projects\netbeans\schoolofdb\target_musicSystemsdb\misc\db-derby-10.6.2.1-bin\db-derby-10.6.2.1-bin\lib\derby.jar

    [/code]


    [code]

     <comment>DTD FOR Schoolofdb project</comment>
      <!--
      Derby Config
      ******************************************************************************************************** config-->
        <entry key="derbyDriver">org.apache.derby.jdbc.EmbeddedDriver</entry>
        <entry key="derbyURL">jdbc:derby:</entry>
      <!--

    [/code]

    • Moved by Just Karl Friday, August 1, 2014 9:55 PM Off-Topic
    Wednesday, August 7, 2013 5:47 PM

Answers

  • Hello,

    I'd have asked the netbeans people.

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

    • Proposed as answer by Just Karl Monday, August 4, 2014 2:12 PM
    • Marked as answer by Just Karl Friday, September 19, 2014 9:17 PM
    Friday, August 1, 2014 9:54 PM

All replies

  • Hello,

    The Windows Desktop Perfmon and Diagnostic tools forum is to discuss performance monitor (perfmon), resource monitor (resmon), and task manager, focusing on HOW-TO, Errors/Problems, and usage scenarios.

    Since your post is off-topic, I am moving it to the off topic forum.

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

    Friday, August 1, 2014 9:43 PM
  • Hello,

    I'd have asked the netbeans people.

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

    • Proposed as answer by Just Karl Monday, August 4, 2014 2:12 PM
    • Marked as answer by Just Karl Friday, September 19, 2014 9:17 PM
    Friday, August 1, 2014 9:54 PM