Skip to content
Advertisement

Runtime.getRuntime().exec could not execute/show Tabtip.exe

I’ve set this OnClick method in JavaFX SceneBuilder on a text field that will pop up the Windows 8 touch keyboard if the user select the textfield. However it seems to be nothing happen when I click on the textfield but when I try to check Tabtip.exe in the task manager, it did shown up there. The codes are:

try

{ 
 Runtime rt = Runtime.getRtuntime();
 rt.exec( "cmd /c C:\Programs Files\Common Files\Microsoft Shared\ink\TabTip.exe");
}


catch 
{
  ex.printStackTrace();
}

There is not errors triggered or whatsoever, and TabTip.exe is running in task manager, but the pop up keyboard does not show up, anyone has any solution to this? Thanks!

Advertisement

Answer

Whenever you want to execute a command which contains spaces in command prompt, you have to wrap it in double quotes.

Like this:

String commandStr = "cmd /c "C:\Program Files\Common Files\Microsoft Shared\ink\mip.exe"";
rt.exec( commandStr );

And In addition to that, if you want to know your errors, you can get error stream from object of class Process which is returned by runtimeObject.exec().

String commandStr =  "cmd /c C:\Programs Files\Common Files\Microsoft Shared\ink\TabTip.exe";   // Like you did

InputStream is = rt.exec( commandStr ).getErrorStream();
int b;
while((b=(is.read()))!=-1)
  System.out.print((char)b);
}
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement