Running Java applications programmtically!! [message #216436] |
Mon, 18 June 2007 04:56 |
Eclipse User |
|
|
|
Hi All,
I am trying to invoke a Java application programmatically from within
plugin using as mentioned in the Eclipse FAQ How do I launch a Java
Program?
http://wiki.eclipse.org/index.php/FAQ_How_do_I_launch_a_Java _program%3F
Following snippet shows the means I am trying to acheieve the same:
void launch2(IJavaProject proj, String main) throws CoreException {
try{
IVMInstall vmInstall = JavaRuntime.getVMInstall(proj);
if (vmInstall == null)
vmInstall = JavaRuntime.getDefaultVMInstall();
if (vmInstall != null) {
IVMRunner vmRunner =
vmInstall.getVMRunner(ILaunchManager.RUN_MODE);
if (vmRunner != null) {
String[] classPath = null;
try {
classPath = JavaRuntime.computeDefaultRuntimeClassPath(proj);
} catch (CoreException e) {System.out.println("CoreException");
e.printStackTrace(); }
catch(Exception ex){ex.printStackTrace();}
if (classPath != null) {
VMRunnerConfiguration vmConfig =
new VMRunnerConfiguration(main, classPath);
vmConfig.setWorkingDirectory(proj.getProject().getLocation() .toString());
vmConfig.setProgramArguments(new String[]{"-form ",
generatorArgs.getFDLocation(), generatorArgs.getJSPXUserLocation(),
generatorArgs.getJSPOutputLocation(),
generatorArgs.getJavaOutputLocation(),
generatorArgs.getConfigOutputLocation()});
ILaunch launch = new Launch(, ILaunchManager.RUN_MODE, null);
vmRunner.run(vmConfig, launch, null);
}
}
}
}catch(Exception e){
e.printStackTrace();
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.32644 seconds