Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Launching Java programatically on newly genereted file by program
Launching Java programatically on newly genereted file by program [message #238402] Mon, 27 November 2006 16:10
Eclipse UserFriend
Originally posted by: neelesh.thakur.yahoo.com

HI

My program creates a new java file and I want to run this java file
programmtically. To do this I first refresh the workspace and build the
whole workspace and then save it.

try { project.refreshLocal(IResource.DEPTH_INFINITE, null);
project.build(IncrementalProjectBuilder.FULL_BUILD, null);
workSpaceRoot.getWorkspace().save(true, null);
} catch (CoreException e) { e.printStackTrace(); }

after that I run this newly generated file by creating launch
configuration and running this configuration

ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType configType =
Manager.getLaunchConfigurationType(IJavaLaunchConfigurationC onstants.ID_JAVA_APPLICATION);
ILaunchConfigurationWorkingCopy wc;
try {
wc = configType.newInstance(null, "SampleTest");
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJE CT_NAME,project.getName());
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_ TYPE_NAME,
"SampleTest");
ILaunchConfiguration config = wc.doSave();
config.launch(ILaunchManager.RUN_MODE, null);
} catch (CoreException e) { e.printStackTrace(); }

But it gives me exception

java.lang.NoClassDefFoundError: SampleTest
Exception in thread "main"

Question: How can remove this exeption.

If I run the same program again and do not delete the java file from the
last run then it will run java file. I guess it is not able to find the
class file in bin directory.

Can someone suggest me what extra I need to do to make things work in
first run itself.

Thanks.
Neelesh Thakur
Previous Topic:Commit does nothing in Pkg Explorer, Navigator
Next Topic:codecomplention
Goto Forum:
  


Current Time: Tue May 06 20:58:32 EDT 2025

Powered by FUDForum. Page generated in 0.03660 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top