This is an automated email from the ASF dual-hosted git repository.

afs pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git

commit 8cb6824fa212f562d1ae5884b04b7a71b2c0c42c
Author: Andy Seaborne <[email protected]>
AuthorDate: Thu May 28 14:57:45 2026 +0100

    Fix deprecated example command line help
---
 .../src/main/java/org/apache/jena/example/Base.java     | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/jena-examples/src/main/java/org/apache/jena/example/Base.java 
b/jena-examples/src/main/java/org/apache/jena/example/Base.java
index a07ad9ce39..68ffab4b7f 100644
--- a/jena-examples/src/main/java/org/apache/jena/example/Base.java
+++ b/jena-examples/src/main/java/org/apache/jena/example/Base.java
@@ -22,9 +22,16 @@
 package org.apache.jena.example;
 
 
+import java.io.IOException;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
 // Imports
 ///////////////
-import org.apache.commons.cli.*;
+import org.apache.commons.cli.help.HelpFormatter;
+import org.apache.jena.atlas.io.IOX;
 
 /**
  * <p>Base file for <em>Getting Started</em> examples. A place to put shared
@@ -102,8 +109,12 @@ public abstract class Base
             commandLine = new DefaultParser().parse( Base.getOptions(), args );
         }
         catch (ParseException e) {
-            HelpFormatter formatter = new HelpFormatter();
-            formatter.printHelp( "", options );
+            try {
+                String cmdSyntax = "Example("+args.toString()+")";
+                HelpFormatter.builder().get().printHelp(cmdSyntax, null, 
options, null, true);
+            } catch (IOException ioException) {
+                throw IOX.exception(ioException);
+            }
             System.exit( 1 );
         }
 

Reply via email to