Class CompactSourceFilesExamples

java.lang.Object
net.jrodolfo.java_evolution.java25.CompactSourceFilesExamples

public class CompactSourceFilesExamples extends Object
Demonstrates Java 25 compact source files and instance main methods.
  • Constructor Details

    • CompactSourceFilesExamples

      public CompactSourceFilesExamples()
  • Method Details

    • createHelloWorldSource

      public Path createHelloWorldSource(Path directory) throws IOException
      Creates a compact source file that can be launched directly.
      Parameters:
      directory - directory where the source file should be written
      Returns:
      path to the compact source file
      Throws:
      IOException - when the source file cannot be written
    • createGreetingSource

      public Path createGreetingSource(Path directory) throws IOException
      Creates a compact source file that accepts launcher arguments.
      Parameters:
      directory - directory where the source file should be written
      Returns:
      path to the compact source file
      Throws:
      IOException - when the source file cannot be written
    • launch

      public CompactSourceFilesExamples.LaunchResult launch(Path sourceFile, String... arguments) throws IOException, InterruptedException
      Launches a compact source file with the JDK java launcher.
      Parameters:
      sourceFile - compact source file
      arguments - program arguments passed after the source file
      Returns:
      child-process result
      Throws:
      IOException - when the child JVM cannot be started
      InterruptedException - when interrupted while waiting for the child JVM