Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #13613

Re: Self-executing JAR

From Tim Slattery <Slattery_T@bls.gov>
Newsgroups comp.lang.java.programmer
Subject Re: Self-executing JAR
Date 2012-04-17 10:49 -0400
Organization A noiseless patient Spider
Message-ID <9g0ro7dmfsd0pdcdmrb9cgrk77agh2e4jh@4ax.com> (permalink)
References <tvpoo7h83ooo9dk54gghqg8v805mlrkpf3@4ax.com> <i90po791d7luqcjsm4k2h5eoa72i23g8af@4ax.com>

Show all headers | View raw


Tim Slattery <Slattery_T@bls.gov> wrote:

>Tim Slattery <Slattery_T@bls.gov> wrote:
>
>>I must be doing something stupid.
>>
>>I have a very simple command-line program in Eclipse, just a
>>System.out.println("Hello World"). It runs just fine in the IDE. So I
>>use File|Export|Export, and select "Runnable JAR file". A JAR is
>>created. 
>>
>>And it doesn't work. I can double-click on it, or I can call it from a
>>command line. I get nothing. No "Hello world", no error message, no
>>nothing. What have I missed?
>
>More info:
>Here's the class:
>
>
>public class Main {
>	public static void main(String[] args) 
>	{
>	    System.out.println("Here I am!");
>	    try
>	    {
>	        SimpleDateFormat sdf = new
>SimpleDateFormat("MM/dd/yyyy");
>	        sdf.setLenient(false);
>	        Date mydate = sdf.parse("2/29/1900");
>	        System.out.println("Good date: " + mydate.toString());
>	    }
>	    catch (ParseException ex)
>	    {
>	        System.out.println("ParseException: " +
>ex.getMessage());
>	    }
>
>	}
>
>	/* (non-Java-doc)
>	 * @see java.lang.Object#Object()
>	 */
>	public Main() {
>		super();
>	}
>
>I export "Main.jar". To invoke from the command line, I type
>"Main.jar". Nothing but a command prompt. I have jedit installed. If I
>go to its directory and type "jedit.jar", it jumps right up. Therefore
>I assume that the JRE can be found. 

It looks like the problem is not that the program doesn't run, but
that the output from "System.out.println" is being written on the
wind. I included code to write a small file, and that file appears
when I double-click the jar file. So the program runs, but where is
the Standard Output file that System.out.println is supposed to write
to?

I could believe that it's on a console window that vanishes
immediately when I start it be double-clicking it. But when I open a
command window, navigate to the jar's directory and type "main.jar",
the exact same thing happens. The file is created, but the System.out
output is nowhere to be seen.

-- 
Tim Slattery
Slattery_T@bls.gov

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Self-executing JAR Tim Slattery <Slattery_T@bls.gov> - 2012-04-16 14:46 -0400
  Re: Self-executing JAR Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-04-16 12:21 -0700
  Re: Self-executing JAR markspace <-@.> - 2012-04-16 12:22 -0700
  Re: Self-executing JAR Tim Slattery <Slattery_T@bls.gov> - 2012-04-16 16:34 -0400
    Re: Self-executing JAR Lew <lewbloch@gmail.com> - 2012-04-16 14:26 -0700
      Re: Self-executing JAR "John B. Matthews" <nospam@nospam.invalid> - 2012-04-16 21:06 -0400
    Re: Self-executing JAR Knute Johnson <nospam@knutejohnson.com> - 2012-04-16 14:35 -0700
    Re: Self-executing JAR markspace <-@.> - 2012-04-16 14:51 -0700
      Re: Self-executing JAR markspace <-@.> - 2012-04-16 15:00 -0700
      Re: Self-executing JAR Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-04-17 08:31 +0000
        Re: Self-executing JAR markspace <-@.> - 2012-04-17 07:35 -0700
    Re: Self-executing JAR Lew <lewbloch@gmail.com> - 2012-04-16 15:51 -0700
      Re: Self-executing JAR Tim Slattery <Slattery_T@bls.gov> - 2012-04-17 08:56 -0400
    Re: Self-executing JAR Tim Slattery <Slattery_T@bls.gov> - 2012-04-17 10:49 -0400
      Re: Self-executing JAR markspace <-@.> - 2012-04-17 07:57 -0700
        Re: Self-executing JAR Tim Slattery <Slattery_T@bls.gov> - 2012-04-18 09:06 -0400
  Re: Self-executing JAR Roedy Green <see_website@mindprod.com.invalid> - 2012-04-17 04:24 -0700

csiph-web