< prev index next >

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java

Print this page




 187     int run(String[] args) {
 188         if (log == null) {
 189             setLog(new PrintWriter(System.err));
 190         }
 191         try {
 192             optionsHelper.handleOptions(this, args);
 193             if (options.help) {
 194                 optionsHelper.showHelp(PROGNAME);
 195                 return EXIT_OK;
 196             }
 197             if (optionsHelper.listPlugins()) {
 198                 optionsHelper.listPlugins(true);
 199                 return EXIT_OK;
 200             }
 201             if (options.version || options.fullVersion) {
 202                 taskHelper.showVersion(options.fullVersion);
 203                 return EXIT_OK;
 204             }
 205             if (taskHelper.getExistingImage() == null) {
 206                 if (options.modulePath == null || options.modulePath.length == 0) {





 207                     throw taskHelper.newBadArgs("err.modulepath.must.be.specified").showUsage(true);

 208                 }
 209                 createImage();
 210             } else {
 211                 postProcessOnly(taskHelper.getExistingImage());
 212             }
 213 
 214             if (options.saveoptsfile != null) {
 215                 Files.write(Paths.get(options.saveoptsfile), getSaveOpts().getBytes());
 216             }
 217 
 218             return EXIT_OK;
 219         } catch (UncheckedIOException | PluginException | IllegalArgumentException |
 220                  IOException | ResolutionException e) {
 221             log.println(taskHelper.getMessage("error.prefix") + " " + e.getMessage());
 222             if (DEBUG) {
 223                 e.printStackTrace(log);
 224             }
 225             return EXIT_ERROR;
 226         } catch (BadArgs e) {
 227             taskHelper.reportError(e.key, e.args);




 187     int run(String[] args) {
 188         if (log == null) {
 189             setLog(new PrintWriter(System.err));
 190         }
 191         try {
 192             optionsHelper.handleOptions(this, args);
 193             if (options.help) {
 194                 optionsHelper.showHelp(PROGNAME);
 195                 return EXIT_OK;
 196             }
 197             if (optionsHelper.listPlugins()) {
 198                 optionsHelper.listPlugins(true);
 199                 return EXIT_OK;
 200             }
 201             if (options.version || options.fullVersion) {
 202                 taskHelper.showVersion(options.fullVersion);
 203                 return EXIT_OK;
 204             }
 205             if (taskHelper.getExistingImage() == null) {
 206                 if (options.modulePath == null || options.modulePath.length == 0) {
 207                     Path jmodsDir = Paths.get(System.getProperty("java.home"), "jmods");
 208                     if (Files.isDirectory(jmodsDir)) {
 209                         options.modulePath = new Path[1];
 210                         options.modulePath[0] = jmodsDir;
 211                     } else {
 212                         throw taskHelper.newBadArgs("err.modulepath.must.be.specified").showUsage(true);
 213                     }
 214                 }
 215                 createImage();
 216             } else {
 217                 postProcessOnly(taskHelper.getExistingImage());
 218             }
 219 
 220             if (options.saveoptsfile != null) {
 221                 Files.write(Paths.get(options.saveoptsfile), getSaveOpts().getBytes());
 222             }
 223 
 224             return EXIT_OK;
 225         } catch (UncheckedIOException | PluginException | IllegalArgumentException |
 226                  IOException | ResolutionException e) {
 227             log.println(taskHelper.getMessage("error.prefix") + " " + e.getMessage());
 228             if (DEBUG) {
 229                 e.printStackTrace(log);
 230             }
 231             return EXIT_ERROR;
 232         } catch (BadArgs e) {
 233             taskHelper.reportError(e.key, e.args);


< prev index next >