GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add --loop option for better hotswap demoing. · mgagui/sample-java-project@e71924f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .gitignore
  • build.xml
  • src/sample/java/project
    • SampleJavaProject.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.gitignore‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
build
22
dist
33
lib
4+
cache.properties
Collapse file

‎build.xml‎

Copy file name to clipboardExpand all lines: build.xml
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
description="Run the application in hotswap mode.">
7373
<java jar="${dist.dir}/${jar.file}" fork="true">
7474
<jvmarg line="-Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n"/>
75+
<arg value="--loop"/>
76+
<arg value="--name"/>
77+
<arg value="Java"/>
7578
</java>
7679
</target>
7780

Collapse file

‎src/sample/java/project/SampleJavaProject.java‎

Copy file name to clipboardExpand all lines: src/sample/java/project/SampleJavaProject.java
+18-5Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
package sample.java.project;
22

3-
import org.apache.commons.cli.Option;
4-
import org.apache.commons.cli.Options;
5-
import org.apache.commons.cli.GnuParser;
3+
import java.util.Timer;
4+
import java.util.TimerTask;
65
import org.apache.commons.cli.CommandLine;
6+
import org.apache.commons.cli.GnuParser;
77
import org.apache.commons.cli.HelpFormatter;
8+
import org.apache.commons.cli.Option;
9+
import org.apache.commons.cli.Options;
810

911
/**
1012
* The main class.
1113
*
1214
* This is the main class of the application. It contains the main()
1315
* method, the first method called.
1416
*/
15-
public class SampleJavaProject {
17+
public class SampleJavaProject extends TimerTask {
18+
19+
/** The delay between printed messages. */
20+
private static final long PRINT_DELAY = 1000L;
1621

1722
/** The name to printed in the output message. */
1823
private static String name = "world";
@@ -28,6 +33,7 @@ public static void main(final String[] args) {
2833
/* Set up the command line arguments. */
2934
Options options = new Options();
3035
options.addOption(new Option("name", true, "set the user's name"));
36+
options.addOption(new Option("loop", "print endlessly, hotswap demo"));
3137
options.addOption(new Option("help", "print this help message"));
3238
CommandLine line = null;
3339
try {
@@ -46,8 +52,15 @@ public static void main(final String[] args) {
4652
if (line.hasOption("name")) {
4753
name = line.getOptionValue("name");
4854
}
55+
if (line.hasOption("loop")) {
56+
new Timer().schedule(new SampleJavaProject(), 0L, PRINT_DELAY);
57+
} else {
58+
new SampleJavaProject().run();
59+
}
60+
}
4961

50-
/* Print out our message. */
62+
@Override
63+
public final void run() {
5164
System.out.printf("Hello, %s!\n", name);
5265
}
5366

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.