Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Knute Johnson Newsgroups: comp.lang.java.programmer Subject: Re: Self-executing JAR Date: Mon, 16 Apr 2012 14:35:56 -0700 Organization: A noiseless patient Spider Lines: 63 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 16 Apr 2012 21:35:57 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="mz/LDSJwiWnk3Jnnqg7x+Q"; logging-data="18928"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18KDOZlnPD6BNIDv4nz+yp9" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 In-Reply-To: Cancel-Lock: sha1:0tkvyNeAINfCKpIhrA6Z/YA6NFQ= Xref: csiph.com comp.lang.java.programmer:13594 On 4/16/2012 1:34 PM, Tim Slattery wrote: > Tim Slattery 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. > You are missing something here, that can't compile as it is. Try compiling from the command line. javac Main.java and if that produces no errors, then run it with java Main -- Knute Johnson