import java.util.*;import java.io.*;class Notepad {public static void main(String[] args) {Runtime rs = Runtime.getRuntime();try {rs.exec("notepad");}catch (IOException e) {System.out.println(e);}}}Explanation:getRunTime method is used to get reference of current RunTime object, exec method can be used to execute commands. You can also specify a file while opening notepad such as exec("notepad programming.txt") where xist in current working directory then a dialog box will be displaye'programming.txt' is the file you wish to open, if the file doesn't ed to create file. You can launch other applications using exec method, for is present in a directory which is not set in environment varia example exec("calc") will launch calculator application. If an application ble PATH then you can specify complete path of application. If you are still using Notepad for Java development it is recommended to switch
to some advanced text editor like Notepad++ or use a development IDE.
Subscribe to:
Post Comments (Atom)
social counter
Popular Posts
-
/* Pyramid 5 Example This Java Pyramid example shows how to generate pyramid or triangle like given below using for loop. 12345 1234 ...
-
import java.io.File; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform...
-
First Way First of all you need to enable SSL for your server. For Tomcat you need to generate an openSSL keystore and add the follow...
-
There are a number of features in Java that have no equivalent in C++. Perhaps the three most important are multithreading, packages, and ...
-
There are some primary differences between http and https, however, beginning with the default port, which is 80 for http and 443 for ...
recent posts
category
popular
-
There are some primary differences between http and https, however, beginning with the default port, which is 80 for http and 443 for ...
-
First Way First of all you need to enable SSL for your server. For Tomcat you need to generate an openSSL keystore and add the follow...
-
Since objects are dynamically allocated by using the new operator, you might be wondering how such objects are destroyed and their memory ...
-
import java.io.File; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform...
-
The increased security that HTTPS brings might suggest that it should be used as a matter of course, but there are drawbacks that must be ...
-
In case you need Oracle Java instead of OpenJDK in Ubuntu, here's how you can install it via a PPA: sudo add-apt-repository ppa:...
-
There are a number of features in Java that have no equivalent in C++. Perhaps the three most important are multithreading, packages, and ...
-
Following example demonstrates how to view current classpath using echo command. C:> echo %CLASSPATH% Result: The above code s...
-
This example fill (initialize all the elements of the array in one short) an array by using Array.fill(arrayname,value) method and Array...
-
Following example demonstrates how to set multiple classpath. Multiple class paths are separated by a semicolon. c:> java -classpath ...

No comments: