KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > launch4j > example > ConsoleApp


1 /*
2     Launch4j (http://launch4j.sourceforge.net/)
3     Cross-platform Java application wrapper for creating Windows native executables.
4
5     Copyright (C) 2004, 2006 Grzegorz Kowal
6
7     This program is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with this program; if not, write to the Free Software
19     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */

21
22 package net.sf.launch4j.example;
23
24 import java.io.BufferedReader JavaDoc;
25 import java.io.IOException JavaDoc;
26 import java.io.InputStreamReader JavaDoc;
27
28 /**
29  * @author Copyright (C) 2005 Grzegorz Kowal
30  */

31 public class ConsoleApp {
32     public static void main(String JavaDoc[] args) {
33         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("Hello World!\n\nJava version: ");
34         sb.append(System.getProperty("java.version"));
35         sb.append("\nJava home: ");
36         sb.append(System.getProperty("java.home"));
37         sb.append("\nCurrent dir: ");
38         sb.append(System.getProperty("user.dir"));
39         if (args.length > 0) {
40             sb.append("\nArgs: ");
41             for (int i = 0; i < args.length; i++) {
42                 sb.append(args[i]);
43                 sb.append(' ');
44             }
45         }
46         sb.append("\n\nEnter a line of text, Ctrl-C to stop.\n\n>");
47         System.out.print(sb.toString());
48         try {
49             BufferedReader JavaDoc is = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(System.in));
50             String JavaDoc line;
51             while ((line = is.readLine()) != null) {
52                 System.out.print("You wrote: " + line + "\n\n>");
53             }
54             is.close();
55         } catch (IOException JavaDoc e) {
56             System.err.print(e);
57         }
58     }
59 }
60
Popular Tags