Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q4083 How would you execute a file from within a Java file?

You are here: irt.org | FAQ | Java | Q4083 [ previous next ]

Check out the java.lang.Runtime class that provide access to the Java runtime system. This class has various methods that helps to implement system level services.

Here is a sample code which starts the notpad.

import java.lang.System;
import java.lang.Runtime;
import java.io.IOException;
public class loadNotepad
{
public static void main(String args[]) throws IOException 
        {
        Runtime load = Runtime.getRuntime();
        // getRuntime() method is a static method which is used to 
        // obtain access to an object of class Runtime.
        r.exec("C:\\windows\\notpad.exe");
        }
} // End of class loadNotpad

Feedback on 'Q4083 How would you execute a file from within a Java file?'

©2018 Martin Webb