Question

I am getting a compilation error to my code in StateMachine.java class in a Codename One project:

error: cannot find symbol
              getRuntime().
symbol:   method exec(String)
location: class Runtime

the full statement is;

try {    
    Runtime.getRuntime().exec("cmd.exe /c start dir ");
} catch (IOException e) {
    System.out.println("Print this");
}

and is running fine in a plain Java project.

What am i missing?

//===============================================

ADD: ..and to

try {
    Process p = Runtime.getRuntime().exec("cmd /c dir A*");
} catch (IOException e) {
    System.out.println("Print this");
}

I'm also getting an compiler error saying

error: cannot find symbol
     Process 
symbol:   class Process
location: class StateMachine

seems to be blocking the OS/backend reach-- but how, what's the "mentality" behind?

Was it helpful?

Solution

We don't support Runtime.exec and it will obviously not work on a mobile phone where you have neither cmd nor access to other processes running on the device due to process isolation. E.g. iOS maintains a private file system per process so sharing files becomes a problem.

You can use Display.getInstance().execute() to run things like the browser but obviously cmd will never work on a device regardless of the technology you choose.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top