Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Accessing JavaApplicationLaunchShortcut.launch(...)
Accessing JavaApplicationLaunchShortcut.launch(...) [message #250229] Sun, 16 December 2007 18:33 Go to next message
Nicolai Kamenzky is currently offline Nicolai KamenzkyFriend
Messages: 82
Registered: July 2009
Member
Hi!

I want to "Run as -> Java Application" a java file
invoked from my code.

Thus I would like to call the launch(...) method of
JavaApplicationLaunchShortcut which is part of
theorg.eclipse.jdt.debug.ui plugin.

I wonder why, but I can't access the code. I even
tried to use reflection to load "org.eclipse.jdt.
internal.debug.ui.launcher.JavaApplicationLaunchShortcut"
but the class cannot be found although it is there.

I am looking for one of the following two solutions:
1) Accessing JavaApplicationLaunchShortcut directly or
2) Doing it the proper why to look up the registered
extensions at the org.eclipse.debug.ui.launchShortcuts
extension point and invoke launch the functionality.

Any help appreciated!
Nicolai


--

I'm using an evaluation license of nemo since 104 days.
You should really try it!
http://www.malcom-mac.com/nemo
Problem solved [message #250233 is a reply to message #250229] Mon, 17 December 2007 09:58 Go to previous message
Nicolai Kamenzky is currently offline Nicolai KamenzkyFriend
Messages: 82
Registered: July 2009
Member
I solved the problem using the proper way.

Here is my code:

ILaunchShortcut launcher = null;
IConfigurationElement launcherElement = null;

IConfigurationElement[] elements =
Platform.getExtensionRegistry().getConfigurationElementsFor( "org.ecli
pse.debug.ui.launchShortcuts");

for (IConfigurationElement element : elements) {
if
(element.getAttribute("id").equals("org.eclipse.jdt.debug.ui.localJav
aShortcut")) { launcherElement = element;
break;
}
}

try {
launcher = (ILaunchShortcut)
launcherElement.createExecutableExtension("class");} catch
(CoreException e) {
e.printStackTrace();
}

if (launcher != null)
launcher.launch(selection, ILaunchManager.RUN_MODE);

Like Eclipse is doing it I look for plugins that registered a launch
shortcut. Then I look for the "Run as -> Java Application" shortcut
and let the plugin architecture create an instance of the class.
Finally I can call launch(...) on that instance.

Cheers,
Nicolai


--

I'm using an evaluation license of nemo since 105 days.
You should really try it!
http://www.malcom-mac.com/nemo
Previous Topic:How to suppress 'never used locally' warning for annotated method
Next Topic:'unable to instantiate' exception when loading wizardPage
Goto Forum:
  


Current Time: Sat Jul 27 11:50:26 GMT 2024

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

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

Back to the top