Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h3>On <code>Runtime.exec</code></h3> <p>Though perhaps not the most ideal solution, you an execute a shell command as a separate <a href="http://java.sun.com/javase/6/docs/api/java/lang/Process.html" rel="nofollow noreferrer"><code>Process</code></a> using <a href="http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html#exec%28java.lang.String%29" rel="nofollow noreferrer"><code>Runtime.getRuntime().exec(someCommand)</code></a>. There are also overloads that takes parameters as a <code>String[]</code>.</p> <p>This is not an easy solution. Managing a concurrent <code>Process</code> and preventing a deadlock etc is not trivial.</p> <h3>Related questions</h3> <ul> <li><a href="https://stackoverflow.com/questions/1081084/is-java-runtime-execstring-platform-independent">Is java Runtime.exec(String[]) platform independent?</a></li> <li><a href="https://stackoverflow.com/questions/2798425/what-is-the-purpose-of-process-class-in-java">What is the purpose of Process class in Java?</a></li> <li><a href="https://stackoverflow.com/questions/1064259/how-can-i-compile-and-deploy-a-java-class-at-runtime">How can I compile and deploy a java class at runtime?</a></li> <li><a href="https://stackoverflow.com/questions/2858734/compiling-a-class-using-java-code-using-process">Compiling a class using Java code using process</a></li> <li><a href="https://stackoverflow.com/questions/636367/java-executing-a-java-application-in-a-separate-process">Java: Executing a Java application in a separate process</a></li> <li><a href="https://stackoverflow.com/questions/845654/running-a-program-from-within-java-code">Running a program from within Java code..</a></li> </ul> <hr> <h3>On draining <code>Process</code> streams</h3> <p>Generally you can't just <code>waitFor()</code> a <code>Process</code> to terminate; you must also drain its I/O streams to prevent deadlock.</p> <p>From <a href="http://java.sun.com/javase/6/docs/api/java/lang/Process.html" rel="nofollow noreferrer">the API</a>:</p> <blockquote> <p>Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock. </p> </blockquote> <h3>Related questions</h3> <ul> <li><a href="https://stackoverflow.com/questions/64000/draining-standard-error-in-java">Draining Standard Error in Java</a></li> </ul> <hr> <h3>On the Java 6 Compiler API</h3> <p>One option to compiling a Java source code within Java is to use the Java 6 Compiler API. This requires a JDK to be installed (not just a JRE).</p> <h3>See also</h3> <ul> <li><a href="http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/api/javax/tools/JavaCompiler.html" rel="nofollow noreferrer"><code>interface JavaCompiler</code></a> from <a href="http://java.sun.com/javase/6/docs/api/javax/tools/package-summary.html#package_description" rel="nofollow noreferrer"><code>package javax.tools</code></a> <ul> <li><a href="http://www.javabeat.net/articles/73-the-java-60-compiler-api-1.html" rel="nofollow noreferrer">external tutorial article</a></li> </ul></li> </ul> <h3>Related questions</h3> <ul> <li><a href="https://stackoverflow.com/questions/2543439/null-pointer-exception-while-using-java-compiler-api">Null Pointer Exception while using Java Compiler API</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload