/** * Set the Java class to execute. * * @param s the name of the main class. * * @throws BuildException if there is also a {@code jar} or {@code sourcefile} attribute specified */ public void setClassname(String s) throws BuildException { if (getCommandLine().getJar() != null || getCommandLine().getSourceFile() != null) { throw new BuildException( "Cannot use combination of 'jar', 'classname', sourcefile attributes in same command"); } getCommandLine().setClassname(s); }
/** * Set the Java module to execute. * * @param module the name of the module. * * @throws BuildException if there is also a {@code jar} or {@code sourcefile} attribute specified * @since 1.9.7 */ public void setModule(String module) throws BuildException { if (getCommandLine().getJar() != null || getCommandLine().getSourceFile() != null) { throw new BuildException( "Cannot use combination of 'jar', 'module', sourcefile attributes in same command"); } getCommandLine().setModule(module); }
/** * Set the Java source-file to execute. Support for single file source program * execution, in Java, is only available since Java 11. * * @param sourceFile The path to the source file * @throws BuildException if there is also a {@code jar}, {@code classname} * or {@code module} attribute specified * @since Ant 1.10.5 */ public void setSourceFile(final String sourceFile) throws BuildException { final String jar = getCommandLine().getJar(); final String className = getCommandLine().getClassname(); final String module = getCommandLine().getModule(); if (jar != null || className != null || module != null) { throw new BuildException("Cannot use 'sourcefile' in combination with 'jar' or " + "'module' or 'classname'"); } getCommandLine().setSourceFile(sourceFile); }
String module = getCommandLine().getModule(); final String sourceFile = getCommandLine().getSourceFile(); if (classname == null && getCommandLine().getJar() == null && module == null && sourceFile == null) { throw new BuildException("Classname must not be null."); if (!fork && getCommandLine().getJar() != null) { throw new BuildException( "Cannot execute a jar in non-forked mode. Please set fork='true'. "); && getCommandLine().getJar() != null) { log("When using 'jar' attribute classpath-settings are ignored. See the manual for more information.", Project.MSG_VERBOSE);