A simple console program.
Introduction
A simple console program to show stdout redirection. The redirection is enabled through configuration file.
1. Edit a java source file: "X:\demos\src\hello\HelloStdRedir.java"
package hello; public class HelloStdRedir { /** * @param args */ public static void main(String[] args) { // Write something through System.out System.out.println("Hello, System.out!"); // Write something through System.err System.err.println("Hello, System.err!"); // Show a default printStackTrace new Exception().printStackTrace(); } }
2. Enter "X:\demos" directory and compile it to a class file:
X:\>cd demos X:\demos>javac src/hello/HelloStdRedir.java
3. Make a jar file:
X:\demos>jar -cvf hellostdredir.jar -C src hello/HelloStdRedir.class
4. Use Jar2Exe to generate exe file for Windows and Linux separately:
X:\demos>j2ewiz hellostdredir.jar /m hello.HelloStdRedir X:\demos>j2ewiz hellostdredir.jar /m hello.HelloStdRedir /platform linux
5. Edit a configuration file: "X:\demos\hellostdredir.cfg"
stdout out.log stderr err.log
Now we can execute the "hellostdredir.exe".
6. Download the program for reference.
- hellostdredir.zip - 134k, download this demo program.
- demos.7z - 5.75M, all demos in one file.
See Also
- See Stdout Redirect page for more details about Stdout Redirection.