简体   繁体   中英

Call the RCP application from My Menu

I'd like to create a plug-in for my Eclipse. I intend to open a different RCP application from the application menu in Eclipse. So I have an Eclipse RCP application and an Eclipse plug-in. The plug-in extends the Eclipse menu by a command to run my Eclipse RCP app.

How can I call my RCP application from my menu?

I think you confuse Eclipse plug-in with Eclipse RCP application. What exactly are you trying to achieve here? Have you developed a plug-in, eg a ViewPart to extend your version of the Eclipse IDE, for instance Helios 3.6 for Java developers?

Or have you developed a full stand-alone RCP application, which gives you an executable with a blank application window when starting it up?

Could you please specify what you mean by "my menu"? Do you mean the html based start menu? Or do you mean the normal application menu? In case it is indeed a view extension plug-in, you can always run it from "Window" - "Show View" - "Other" and then select your view. You obviously need to deploy your plug-in first (plugin folder in your eclipse path).

These useful tutorials might help you clear things up:

RCP: http://www.vogella.de/articles/EclipseRCP/article.html

Plug-in: http://www.vogella.de/articles/EclipsePlugIn/article.html


EDIT:

Okay, thank you for clearing that up. I assume (I never did that, though) you have two options then. Since your RCP app, once built, should come with a normal runtime binary, you could either use:

  • java.lang.Runtime.exec()

( http://download.oracle.com/javase/6/docs/api/java/lang/Runtime.html )

This is the standard Java way to run executables. It comes with six overloaded versions:

public Process exec(String command);
public Process exec(String[] cmdArray);
public Process exec(String[] cmdarray, String[] envp, File dir);
public Process exec(String command, String[] envp);
public Process exec(String command, String[] envp, File dir);
public Process exec(String[] cmdArray, String[] envp);

So just pick what's best, eg the fourth if you want to hand over arguments. To obtain the Runtime instance:

 Runtime rt = Runtime.getRuntime();
 rt.exec("~/myapp");

You could also "build" the process yourself: http://www.java-tips.org/java-se-tips/java.util/from-runtime.exec-to-processbuilder.html

or use

  • org.eclipse.swt.program.Program

( http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/program/package-summary.html )

This class is originally intended to run files with the OS associated program, eg HTML with the default browser. It can however be used to run normal executables as well.

And just to be complete, to launch Java applications from within Eclipse, you can always follow this guide: http://www.eclipse.org/articles/Article-Java-launch/launching-java.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM