8 Replies - 757 Views - Last Post: 22 August 2013 - 07:44 AM Rate Topic: -----

#1 ceyesumma  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 31
  • Joined: 14-December 10

standalone *.jar will not run execeptions

Posted 31 July 2013 - 07:50 AM

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:

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



and the XML.xml file is in the userdir at:

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




I also use a properties sheet

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



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

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;
    }

   






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." );
    }

}










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));
    }
}






ModelResourcesXML.xml



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





 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);
    }






Is This A Good Question/Topic? 0
  • +

Replies To: standalone *.jar will not run execeptions

#2 ceyesumma  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 31
  • Joined: 14-December 10

Re: standalone *.jar will not run execeptions

Posted 31 July 2013 - 08:06 AM

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


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






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



Was This Post Helpful? 0
  • +
  • -

#3 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2555
  • View blog
  • Posts: 10,660
  • Joined: 20-September 08

Re: standalone *.jar will not run execeptions

Posted 31 July 2013 - 08:30 AM

You need to be careful when both reading AND writing to resource files. Please confirm that's what's occurring..
Was This Post Helpful? 0
  • +
  • -

#4 ceyesumma  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 31
  • Joined: 14-December 10

Re: standalone *.jar will not run execeptions

Posted 07 August 2013 - 10:35 AM

all the reads to xml work in the netbeans enviornment. Is there a way to get some kind of system out while running a standalone exec.jar. When it is running out side of the IDE it
will not act the same as if it were running in the IDE.
thanks
Was This Post Helpful? 0
  • +
  • -

#5 StrongJoshua  Icon User is offline

  • D.I.C Head

Reputation: 43
  • View blog
  • Posts: 136
  • Joined: 19-July 13

Re: standalone *.jar will not run execeptions

Posted 07 August 2013 - 03:49 PM

Check if you're getting any errors by running the .jar in cmd by using the command "java -jar yourJar.jar", without the quotes of course (make sure you navigated to the correct folder before hand or you'll have to extend the path name to whatever is necessary, safest is the entire path name for the file).
Was This Post Helpful? 0
  • +
  • -

#6 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2555
  • View blog
  • Posts: 10,660
  • Joined: 20-September 08

Re: standalone *.jar will not run execeptions

Posted 07 August 2013 - 04:26 PM

Quote

Is there a way to get some kind of system out while running a standalone exec.jar.
stdout and stderr streams don't behave any differently with jars
Was This Post Helpful? 0
  • +
  • -

#7 ceyesumma  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 31
  • Joined: 14-December 10

Re: standalone *.jar will not run execeptions

Posted 13 August 2013 - 09:36 AM

I will have to continue trying to use cmd java –jar ………….maybe the manifest is messed up. Because if I try to run my app from a thumb drive I
can not set the command up to find the drive that the app is running on (not c:\ but F: or G:\ etc.

Thanks I am a little below the learning curve of the basics.

Quote

stdout and stderr streams don't behave any differently with jars


This explanation seem to be the issue. Someone proposed that the app may not be throwing the exception in the first place. That is a mystery to me.
I have been running the app in netbeans for years now and it has always thrown all the exceptions.
Was This Post Helpful? 0
  • +
  • -

#8 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2555
  • View blog
  • Posts: 10,660
  • Joined: 20-September 08

Re: standalone *.jar will not run execeptions

Posted 13 August 2013 - 11:45 AM

Quote

This explanation seem to be the issue. Someone proposed that the app may not be throwing the exception in the first place.
What exception?
If the app is not running in the first place, you won't know why if the association of jars is to javaw.exe as there's no window. That's why it's sometimes better to associate jars with java.exe
Was This Post Helpful? 0
  • +
  • -

#9 ceyesumma  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 31
  • Joined: 14-December 10

Re: standalone *.jar will not run execeptions

Posted 22 August 2013 - 07:44 AM

Thanks for the input. I am trying to run my app outside of netbeans and convert a number of things to run
to adapt to the new operating phase. I have to learn to de-bug and change the app. My rookie mistake consisted of
my view.utiliies.class pointed to the wrong place for where the new location of the XML resources. of course it did not
throw exceptions. Thanks for your time. The app is now finding those resources.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1