Pregunta

I am trying a run a java program(which is not in eclipse) from within eclipse using

Process p1 = Runtime.getRuntime().exec("java " + exec); 

(where exec is the path to the file)

It throws me a could not find or load main class. It actually has a main class and it did compile successfully with the following statement. any help would be appreciated

Process p = Runtime.getRuntime().exec(compiler + " " + file);
¿Fue útil?

Solución

From your comments it seems that your command should probably look like

java -cp c:\users test

so try changing your code to something like

Process p1 = Runtime.getRuntime().exec("java -cp c:\\users " + exec); 

where exec should pass full.package.name.of.YourClass which in your case is most probably test (not test.class or test.java).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top