Class CompactSourceFilesExamples
java.lang.Object
net.jrodolfo.java_evolution.java25.CompactSourceFilesExamples
Demonstrates Java 25 compact source files and instance main methods.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classCaptures the compact source launcher result. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateGreetingSource(Path directory) Creates a compact source file that accepts launcher arguments.createHelloWorldSource(Path directory) Creates a compact source file that can be launched directly.Launches a compact source file with the JDKjavalauncher.
-
Constructor Details
-
CompactSourceFilesExamples
public CompactSourceFilesExamples()
-
-
Method Details
-
createHelloWorldSource
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
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 JDKjavalauncher.- Parameters:
sourceFile- compact source filearguments- program arguments passed after the source file- Returns:
- child-process result
- Throws:
IOException- when the child JVM cannot be startedInterruptedException- when interrupted while waiting for the child JVM
-