1

There is in my Java application the following piece of code:

boolean is64 = System.getProperty("os.arch").contains("64");
String oskPath = is64 ? "/SysWOW64/osk.exe" :"/system32/osk.exe";

Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
    desktop = Desktop.getDesktop();
}
String sysroot = System.getenv("SystemRoot");
try {
    System.out.println("SysArch "+System.getProperty("os.arch")+ " " +is64);
    desktop.open(new File(sysroot + oskPath));

wich calls Windows' On-Screen Keyboard. When I run the .jar on Windows 64bits it's ok, but it doesn't work when I run the .exe. I've tried this:

Runtime.getRuntime().exec("cmd /c " + sysroot + oskPath);

and this:

Runtime.getRuntime().exec("osk");

but the same thing happened. I Created .exe whith launch4j andI tried to convert the .bat (who runs .jar) to .exe but nothing happened.. Can someone please help?. Thanks in advance.

  • Note that `os.arch` does not return the architecture of Windows but of the JRE. See this answer: http://stackoverflow.com/a/2110847 – Tunaki Sep 08 '15 at 11:33
  • what happens if you [capture the output](http://stackoverflow.com/questions/4741878/redirect-runtime-getruntime-exec-output-with-system-setout)? what do you see? – Tschallacka Sep 08 '15 at 11:33
  • See also [When Runtime.exec() won't](http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html) for many good tips on creating and handling a process correctly. Then ignore it refers to `exec` and use a `ProcessBuilder` to create the process. – Andrew Thompson Sep 08 '15 at 13:38

0 Answers0