Kodejava

Learn Java Programming by Examples


How do I execute other applications from Java?

Category: java.lang, viewed: 5K time(s).

The following program allows you to run / execute other application from Java using the Runtime.exec(...) method.

package org.kodejava.sample.java.lang;

import java.io.IOException;

public class RuntimeExec
{
    public static void main(String[] args)
    {
        String command = "explorer.exe";

        try
        {
            Process process = Runtime.getRuntime().exec(command);
        } catch (IOException e)
        {
            e.printStackTrace();
        }
    }
}

More examples on java.lang

  • How do I reverse a string?
  • How do I add leading zeros to a number?
  • How do I split a string?
  • How do I get file separator symbol?
  • How do I terminate a Java application?
  • How do I get operating system temporary directory / folder?
  • What is Autoboxing?
  • How do I remove trailing white space from a string?
  • How do I copy char array to string?
  • How do I calculate process elapsed time?
  • How do I convert string to char array?
  • How do I get package name of a class?
  • How do I check if a character representing a number?
  • How do I get the username of operating system active user?
  • How do I check if a character representing an alphabet?
  • How do I remove substring from StringBuilder?
  • How do I decode string to integer?
  • How do I get Java Home directory?
  • How do I get super class of an object?
  • How do I convert string to an integer or number?

Example Categories

  • JSE

  • fundamental
  • java.applet
  • java.awt
  • java.awt.geom
  • java.beans
  • java.io
  • java.lang
  • java.lang.annotation
  • java.lang.management
  • java.lang.reflect
  • java.math
  • java.net
  • java.nio
  • java.security
  • java.sql
  • java.text
  • java.util
  • java.util.logging
  • java.util.regex
  • java.util.zip
  • javax.crypto
  • javax.print
  • javax.script
  • javax.swing
  • javax.tools
  • javax.xml
  • JSP / Servlet

  • javax.servlet
  • jsp.snippets
  • taglib / jstl
  • JEE

  • javax.mail
  • javax.naming
  • Hibernate

  • org.hibernate
  • MyBatis

  • org.apache.ibatis
  • Design Patterns

  • Factory Patterns
  • Apache Commons

  • commons.beanutils
  • commons.codec
  • commons.dbcp
  • commons.fileupload
  • commons.httpclient
  • commons.io
  • commons.lang
  • commons.net
  • Spring Framework

  • org.springframework
  • org.springframework.jdbc
  • Tapestry

  • Google Web Toolkit

  • GWT Panels
  • GWT Wigdets
  • GWT Listeners
  • Android

  • Others

  • com.google.gson
  • com.itextpdf
  • org.apache.poi
  • org.jasypt
  • org.jdom
  • org.joda.time

100 Top & Latest

  • Top 100 Codes
  • Latest 100 Codes
  • Browse All Codes

Network Sites

  • Learn C# by Examples
  • Programming Tutorials and Resources

Navigation

  • Home
  • Project Board
  • Free Magazines
  • Advertise
  • Links
  • RSS Feed
  • Donation
  • Follow @kodejava

The examples provided here are for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user.
Kodejava.org is a member of Kodesoft.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.