Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.

How can I launch an application or process in Silk4J without using the base state?

How can I launch an application or process in Silk4J without using the base state?

If you want to launch an application for example a basic batch file then you can do so by using the Runtime() class and executing the specified process by passing in the command required to launch the application. Typically this can be achieved as shown below:

 public void run1()  
  try {    
       Runtime.getRuntime().exec("cmd.exe /c C:\\LaunchNotepad.bat");   
  } catch (IOException e)
     {    e.printStackTrace();   

However if the application path contains “spaces” in the path (e.g. Program Files (x86)) then this can cause a problem as the exec() method will try and invoke the application from the current workspace. Therefore to overcome this issue you need to run 2 separate command via the exec() method.

Command 1: To change the directory to the directory which contains the batch or jar file
Command 2: To start the actual application from the currently directory

This can be achieved by using: && [...]  command1 && command2

Please note that Cmd.exe runs the first command, and then runs the second command only if the first command completed successfully.

Below is some sample code demonstrating the use of this command:


  public void run2()  
  Runtime rt = Runtime.getRuntime();  
  try {
     Process proc = rt.exec("cmd.exe /C \"cd C:\\Program Files (x86)\\Silk\\SilkTest\\ng\\sampleapplications\\java\\swing && start SwingTestApp.bat");      
      } catch (IOException e) {    


Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2014-10-03 09:53
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.