More switching to {java command line}

This commit is contained in:
Bruce Eckel 2016-07-28 13:42:03 -06:00
parent 72c57ddee3
commit dc3172ce90
22 changed files with 24 additions and 27 deletions

View File

@ -4,7 +4,7 @@
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Non-informative style of assert
// Must run with -ea:
// {JVMArgs: -ea}
// {java -ea Assert1}
// {ThrowsException}
public class Assert1 {

View File

@ -3,7 +3,7 @@
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Assert with an information-expression
// {JVMArgs: -ea}
// {java Assert2 -ea}
// {ThrowsException}
public class Assert2 {

View File

@ -41,12 +41,6 @@ class Tags {
errorOutputExpected = hasTag('ErrorOutputExpected')
validateByHand = hasTag('ValidateByHand')
ignoreOutput = hasTag('IgnoreOutput')
def argString = extract('Args:')
if(argString)
args = argString.split(' ')
def jvmArgString = extract('JVMArgs:')
if(jvmArgString)
jVMArgs = jvmArgString.split(' ')
exec = extract('Exec:')
runFirst = extract('RunFirst:')
lines.each {

View File

@ -4,7 +4,7 @@
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Demonstrates performance differences in Lists
// Small to keep build testing short:
// {Args: 100 500}
// {java ListPerformance 100 500}
import java.util.*;
import onjava.*;

View File

@ -4,7 +4,7 @@
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Demonstrates performance differences in Maps
// Small to keep build testing short:
// {Args: 100 5000}
// {java MapPerformance 100 5000}
import java.util.*;
public class MapPerformance {

View File

@ -3,7 +3,7 @@
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Does Math.random() produce 0.0 and 1.0?
// {Args: lower}
// {java RandomBounds lower}
import onjava.*;
public class RandomBounds {

View File

@ -4,7 +4,7 @@
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Demonstrates performance differences in Sets
// Small to keep build testing short:
// {Args: 100 5000}
// {java SetPerformance 100 5000}
import java.util.*;
public class SetPerformance {

View File

@ -2,7 +2,7 @@
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// {Args: GZIPcompress.java}
// {java GZIPcompress GZIPcompress.java}
// {ValidateByHand}
import java.util.zip.*;
import java.io.*;

View File

@ -4,7 +4,7 @@
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Uses Zip compression to compress any
// number of files given on the command line
// {Args: ZipCompress.java}
// {java ZipCompress ZipCompress.java}
// {ValidateByHand}
import java.util.zip.*;
import java.io.*;

View File

@ -2,7 +2,7 @@
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// {Args: VendingMachineInput.txt}
// {java VendingMachine VendingMachineInput.txt}
import java.util.*;
import java.io.IOException;
import java.util.function.*;

View File

@ -3,7 +3,7 @@
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Configure and execute the greenhouse system
// {Args: 5000}
// {java GreenhouseController 5000}
import innerclasses.controller.*;
public class GreenhouseController {

View File

@ -2,7 +2,8 @@
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// {JVMArgs: -Djava.util.logging.config.file=log.prop}
// {java ConfigureLogging
// -Djava.util.logging.config.file=log.prop}
// {ErrorOutputExpected}
import java.util.logging.*;

View File

@ -3,7 +3,7 @@
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Copying a file using channels and buffers
// {Args: ChannelCopy.java test.txt}
// {java ChannelCopy ChannelCopy.java test.txt}
import java.nio.*;
import java.nio.channels.*;
import java.io.*;

View File

@ -3,7 +3,7 @@
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Using transferTo() between channels
// {Args: TransferTo.java TransferTo.txt}
// {java TransferTo TransferTo.java TransferTo.txt}
import java.nio.channels.*;
import java.io.*;

View File

@ -3,7 +3,8 @@
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// A very simple version of the "grep" program
// {Args: WhitherStringBuilder.java 'return|for|String'}
// {java JGrep
// WhitherStringBuilder.java 'return|for|String'}
import java.util.regex.*;
import java.nio.file.*;
import java.util.stream.*;

View File

@ -3,7 +3,8 @@
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Simple regular expression demonstration
// {Args: abcabcabcdefabc "abc+" "(abc)+" }
// {java TestRegularExpression
// abcabcabcdefabc "abc+" "(abc)+" }
import java.util.regex.*;
public class TestRegularExpression {

View File

@ -3,7 +3,7 @@
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Using queues and multithreading
// {Args: 5}
// {java BankTellerSimulation 5}
import java.util.concurrent.*;
import java.util.*;

View File

@ -3,7 +3,7 @@
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Demonstrates how deadlock can be hidden in a program
// {Args: 0 5 timeout}
// {java DeadlockingDiningPhilosophers 0 5 timeout}
import java.util.concurrent.*;
public class DeadlockingDiningPhilosophers {

View File

@ -3,7 +3,7 @@
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Dining philosophers without deadlock
// {Args: 5 5 timeout}
// {java FixedDiningPhilosophers 5 5 timeout}
import java.util.concurrent.*;
public class FixedDiningPhilosophers {

View File

@ -4,7 +4,7 @@
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Rewriting innerclasses/GreenhouseController.java
// to use a ScheduledThreadPoolExecutor
// {Args: 5000}
// {java GreenhouseScheduler 5000}
import java.util.concurrent.*;
import java.util.*;

View File

@ -4,7 +4,7 @@
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Operations that might seem safe are not,
// when threads are present
// {Args: 4}
// {java SerialNumberChecker 4}
import java.util.concurrent.*;
// Reuses storage so we don't run out of memory:

View File

@ -4,7 +4,7 @@
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Using reflection to show all the methods of a class,
// even if the methods are defined in the base class
// {Args: ShowMethods}
// {java ShowMethods ShowMethods}
import java.lang.reflect.*;
import java.util.regex.*;