Difference between running a java application as jar or via batch file?Hi,

Hi,
I'm facing some strange differences in the behavior of my application , only caused by different methods to execute the application . So I have know the potential difference between these methods to locate the error.
1) running my application it with java -jar (via batch-file or command-prompt) or in eclipse works fine
2) executing the jar by double click causes problems.
The difference I know are that you can easily pass arguments to jvm, when using the jar.Maybe there is a differences in thread scheduling, but I'm not sure about that.
Can anyone tell me, the differences between these to methods of execution?
Thanks a lot in advance.
Greetings Michael

Hi,
to get a clue I have redirected the System.err and System.out to a TextArea
(see code below) and suddenly the error was gone. So according to the behavior that it had worked before in the ide and via batch file where the System stream can do unlimited writing. I think it is obvious, that something goes wrong with streams of System.
Does anyone knows what happens to messages which are send to the default streams, when running the app as jar? I normally would assume that they would point to /dev/null or something else, but as I have experienced it seems that they are blocking after a certain amount, which prevented my app from working. (By the way invoking it with javaw has the same effect.)
This goes a little bit off topic, perhaps I should post a new thread.
But this is a huge difference between java and and javaw (jar), I wasn't aware of i t until now.
Hope someone can explain me how javaw handles System.err and System.out.
Thanks for your participation.
Greetings Michael
@SuppressWarnings("unused")
     private static void debug(){
          /* Debug Jar-File if no console exists */
          final JTextArea ta = new JTextArea(25, 80);
          ta.setWrapStyleWord(true);
          final JScrollPane jscp = new JScrollPane(ta);     
          class TextAreaPrintStream extends PrintStream {
               private JTextArea consoleTextArea;
               TextAreaPrintStream(JTextArea consoleTextArea, OutputStream out) {
                    super(out);
                    this.consoleTextArea = consoleTextArea;
               /* (non-Javadoc)
                * @see java.io.PrintStream#println(java.lang.String)
               @Override
               public void println(String x) {
                    this.consoleTextArea.append(x +'\n');
               /* (non-Javadoc)
                * @see java.io.PrintStream#print(java.lang.String)
               @Override
               public void print(String s) {
                    this.consoleTextArea.append(s);
          TextAreaPrintStream out = new TextAreaPrintStream(ta, System.out);
          TextAreaPrintStream err = new TextAreaPrintStream(ta, System.err);
          System.setOut(out);
          System.setErr(err);
          JDialog dialog = new JDialog( (Frame) null, "Log" , false);
          dialog.setContentPane(jscp);
          dialog.setSize(dialog.getPreferredSize());
          dialog.setVisible(true);
          System.err.println("Test Error");
     Used proposed solution from sn.schulz :
http://forum.java.sun.com/thread.jspa?forumID=257&threadID=213477

Similar Messages

  • Difference between web server and application server

    Hi Everybody
    Could anybody expain difference between web server and application server?
    Sharad

    Hi there
    The difference I know is the application servers provides the containers for the applications to run which is not provided by the web servers.
    For example the containers can be an EJB container or JSP container etc

  • Running a Java Application in Windows

    Hi, Can anyone tell me how to run a Java Application in Windows? I've tried to run it using TextPad 4.5 but it gives me an exception saying it can't find a class defenition. I'm actually using IBM VisualAge for Java to develop the app and it runs fine INSIDE VisualAge and I've exported my compiled class files and so on, to run it stand-alone in Windows. I'm using some custom objects and inner classes, could these be the problem?

    YES! SUCCESS! I exported my class files from VAJ and along with the manifest file that it adds automatically. I opened up the jar with Winrar, extracted the manifest file and added the Main-class: header pointing to my executable and then put it back in the jar with winrar. And PRESTO! I can now run it with javaw! Thanks for your help peeps...

  • How do i run a java application in jdk1.3

    im trying to run a java application in jdk 1.3. I created it in jbuilder and i was trying to use the applet viewer.

    http://java.sun.com/j2se/1.3/docs/tooldocs/win32/appletviewer.html
    Jesper

  • How can I run a java-application on starting of Windows 2000

    How can I run a java-application without any user on starting of Windows 2000?
    For example, if the computer is restarted and nobody enter into it yet, my java-application should run anyway.
    How can I do that?

    Hi, you have to put it in a Windows service.
    To do this you have a program, Srvany.exe that allow to insert a .exe or .bat program in a Windows service.
    For example, i develop a program, TomcatGuardian and i put it in a service because i need to run it in a server without Administrator logged in.
    Regards,
    Ivan.

  • Running a java application from a java application

    hello ,
    please who knows how i can run a java application 'B' from inside another java application 'A' and get the error messages (if any) from the application 'B'

    how are you executing application B from application A? Please explain the java code you are using?

  • Running a Java application from a Swing GUI

    Hi,
    I was wondering if there is a simple way to run a Java application from a GUI built with Swing. I would presume there would be, because the Swing GUI is a Java application itself, technically.
    So, I want a user to click a button on my GUI, and then have another Java application, which is in the same package with the same classpaths and stuff, run.
    Is there a simple way to do this? Do any tutorials exist on this? If someone could give me any advice, or even a simple "yes this is possible, and it is simple" or "this is possible, but difficult" or "no this is not possible" answer, I would appreciate it. If anyone needs more information, I'll be happy to provide it.
    Thanks,
    Dan

    I don't know if it is possible to run the main method from another Java app by simply calling it...
    But you could just copy and paste the stuff from your main method into a new static method called something like runDBQuery and have all the execution run from there.
    How does that sound? Is it possible?
    What I'm suggeting is:
    Original
    public class DBQuery{
    public static void methodA(){
    public static void doQuery(){
    methodA();
    public static void main(String[] args){
    // Your method calls
    //Your initializing
    doQuery();
    }Revised:
    public class DBQuery{
    public static void methodA(){
    public static void doQuery(){
    methodA();
    public static void doMyQuery(){
    // Your method calls
    //Your initializing
    doQuery();
    // No main needed!!
    //public static void main(String[] args){
    // Your method calls
    //doQuery();
    //}

  • Running a java application in command prompt

    hi, I'm new to this forum.
    I would like to know what exactly needs to be specified to run a java application in a normal DOS command prompt.
    I know it is something like:
    javaw -classpath .\class GUI.applicationGUI
    where applicationGUI is the main class, right? What else do I need to do, since I have some other non-GUI classes that I need, inside the class folder ?
    Thanks for your time.

    You need to import those classes. And you need to make packages.
    In classes 1, 2 and 3 put:
    package class;
    In class 4 put;
    package class.GUI;
    Then you need to make the connection:
    In classes 1,2 and 3 put:
    import class.GUI.*;
    In class 4 put:
    import class.*;
    Compile each directory separately while in the respective directory. javac *.java
    Then go back to the directory above the directory "class" and run
    java class/GUI/name_of_file_containing_main_method

  • Difference between component configuration and application configuration in webdynpro

    what is the difference between component configuration and application configuration in webdynpro?

    Hi Rohit,
    With the component configuration, you can control the behavior of each individual component within a Web Dynpro application or the user interface of individual views. For each component, several records of configuration data can be created.
    Using the application configuration, it is now possible to assign the configuration required in the current application to all the components used.
    In short : Component Config belongs to WDP Component and Appl'n Config. belongs to WDP Appl'n.
    Check this document for more information.
    Web Dynpro for ABAP - Component and Application Configuration
    Thanks
    KH

  • Is it possible to run a java application within a web browser?

    Hello everyone here! I have a question about running a java application within a web browser and I would appreciate it very much if anyone here can give me some answers.
    I have a standalone java application written with AWT. Basically this free application lets users to select spectral lines from a big file based on some criteria and plot those selected lines. Yes, it is a very simple application. Now I want to run this application within a web browser so that users don't need to download the application from the ftp site and thus don't need to install in their machine. Is it possible to run this application within browser? If yes, can we get the same plotting function as we run the application separately and where should I start out?
    Thanks in advance!
    kuilian

    Please see the signed applet discussion group for details of how to avoid the applet security restrictions. You can sign the applet, or use the policy file containing {AllPermission} for testing purposes (though not suitable for widespread deployment).
    Regards
    Matthew

  • Can we run a java application using Runtime.exec()?

    Can we run a java application using Runtime.exec()?
    If yes what should i use "java" or "javaw", and which way?
    r.exec("java","xyz.class");

    The best way to run the java application would be to dynamiically load it within the same JVM. Look thru the class "ClassLoader" and the "Class", "Method" etc...clases.
    The problem with exec is that it starts another JVM and moreover you dont have the interface where you can throw the Output directly.(indirectly it can be done by openong InputStreams bala blah............). I found this convenient. I am attaching part of my code for easy refernce.
    HIH
    ClassLoader cl = null;
    Class c = null;
    Class cArr[] ;
    Method md = null;
    Object mArr[];
    cl = ClassLoader.getSystemClassLoader();
    try{
         c = cl.loadClass(progName.substring(0,progName.indexOf(".class")) );
    } catch(ClassNotFoundException e) {
    System.out.println(e);
         cArr = new Class[1] ;
         try{
         cArr[0] = Class.forName("java.lang.Object");
         } catch(ClassNotFoundException e) {
         System.out.println(e);
         mArr = new Object[1];
         try{
         md = c.getMethod("processPkt", cArr);
         } catch(NoSuchMethodException e) {
         System.out.println(e);
         } catch(SecurityException e) {
         System.out.println(e);
    try {            
    processedPkt = md.invoke( null, mArr) ;
    } catch(IllegalAccessException e) {
              System.out.println(e);
    } catch(IllegalArgumentException e) {
              System.out.println(e);
    }catch(InvocationTargetException e) {
              System.out.println(e);
    }catch(NullPointerException e) {
              System.out.println(e);
    }catch(ExceptionInInitializerError e) {
              System.out.println(e);
    }

  • Difference Between central instance And application instance

    Hi every body can any one tell me that
    what is the difference between Central instance and Application instance.
    If i am using 4.7 ee with orcale data base.

    Check these links
    http://oreilly.com/catalog/sapadm/chapter/ch01.html
    Basically these terms comes when you are working on live servers where all the users log into to do their daily work.
    We says when we want to distribute the workload on servers we requires central instance and application servers.
    Normally it is not known to common users where they are logging into...but they can login directly usign the specific Instance details of servers.
    Please see this also
    http://help.sap.com/saphelp_nw2004s/helpdata/en/c4/3a64e8505211d189550000e829fbbd/frameset.htm

  • Difference between Business message and application message

    Hi B2B Gurus,
    Can you please explain the difference between Business message and application message?
    Regards,
    Praveen

    Hi Praveen,
    Business message status reports identify business message instance details for a document protocol. These details include the sending and receiving trading partners, the agreement name, the business action, the business message ID, the status, the exchange protocol and document protocol, and message details.
    Application Message Reports provide information related to the SOA Composite—the name, version, and so on, if a back-end composite application sent or received the message.
    Regards,
    Anuj

  • Difference between web dynpro java and web dynpro abap

    Hi this is watson maureen,
                 I wnat to know what is  the difference between web dynpro java and web dynpro abap?
    thank
    maureen

    Hi watson,
    Go through these links, you will get the difference between web dynpro java and web dynpro abap
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e0e4940c-035c-2b10-0b9d-eb8f99674f4e
    Web Dynpro: ABAP or Java?
    Regards
    Sreedhar.

  • Proble regarding running a java application

    hi guys
    i'm new to java environment .
    when i'm running a java application in a console ,
    it is not able to give output in other directories.it is working only in c:\j2sdk\bin.
    i think its the problem of setting classpath.
    can any one help me hw to run java program in any folder.

    You need to add that directory to your PATH. Follow
    the installation instructions more completely.Howdy sheriff Warnerja! How's life in the Schmuckville Home of the Ball-less? Any leads regarding the dot flasher case? I see you're on the PATH.
    Sheriff Warnerja of Schmuckville sensed an indecency plot.
    Here was someone exposing her private dot.
    He went on the trail,
    but of no avail:
    He didn't know where to find that intimate spot!

Maybe you are looking for

  • Need to send an attachment with the mail to the distribution list

    Hi all, How do I send an <b>attachment</b> with the e-mail to a distribution list? I am using the FMs <b>SO_DLI_EXPAND</b> and <b>SO_OBJECT_SEND</b> to expand the distribution list and send mail to the distribution list respectively.I am getting the

  • Thumbnails for large files

    OK..so now I've learned that for my large panorama filesI wont get a thumbnail in the Organizer. Just some Blue Triangle warning with a exclamation point. I do allot of golf course work where I stitch phototos and print 38 x 11 inches @ 300dpi. So wh

  • Camera Raw 5.2 and DNG Converter Available - Note from Adobe

    Camera Raw 5.2 and the DNG Converter is now available: http://blogs.adobe.com/lightroomjournal/2008/11/camera_raw_52_and_dng_converte.html Lightroom will be updated to version 2.2 with equivalent camera support in December. Regards, Tom Hogarty Light

  • I have problem with my Notebook fan. it don't work. what can i do ?

    hi. my name is maziyar. i have problem with my notebook fan it does not work. and it got hot. what can i do ? i don't know why. can you help me ? there is any where in IStanbul (Turkey) that i can show my Notebook. thanks maziyar kosarifar

  • Google Mail (Gmail) Sync Issues

    After I put my computer into sleep, then wake it up, Mail stops syncing or retrieving new mail from Gmail server. Am I the only one who's having this problem? I tried deleting the account and logging in again, but it didn't change anything. Any solut