Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Create Batch file to repeat IDE-like launch from external
Create Batch file to repeat IDE-like launch from external [message #643193] Sun, 05 December 2010 23:09 Go to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 179
Registered: July 2009
Senior Member
My use scenario is kind of unusual...

I have a RCP application in the Run configuration in the Eclipse IDE. And i want to be able to rerun the application from outside (Batch file), without the need of eclipse running or exporting the application. This is because I want short edit/compile/run cycles, but the run step shall be done outside. However....

If I only could find out all arguments Eclipse is passing to the started VM, then I could create a batch file for the current installation.

What I tried:

I used System properties to get the classpath, which has the path to the org.eclipse.equinox.launcher_1.1.0.v20100507.jar.

Then I throw an exception in the application to get an error log and used the line:
Command-line arguments: -product .........
Now I build a java call like:

C:\TestEnv>java -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx512m -jar C:\Eclipse36\eclipse\plugins\org.eclipse.equinox.launcher_1. 1.0.v20100507.jar -product TestEnv.product -data C:\Eclipse36\workspace/../runtime-TestEnv.product -dev file:C:/Eclipse36/workspace/.metadata/.plugins/org.eclipse.p de.core/TestEnv.product/dev.properties -os win32 -ws win32 -arch x86 -consoleLog

What happens is, I get another error output, "!MESSAGE Product TestEnv.product could not be found." and a window comes up with the menus from eclipse.

1. What am I doing wrong? How can I make the launcher find my product?
I am using the same working directory. The TestEnv.product file is there and the bin directory also (there is reference to it in workspace dev.properties)
2. How can I get the needed information automatically? (e.g. without forcing an error log to be written)

Frank
Re: Create Batch file to repeat IDE-like launch from external [message #643201 is a reply to message #643193] Mon, 06 December 2010 00:38 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 179
Registered: July 2009
Senior Member
I got the answer to the first question...

I replaced the launcher.jar with an own version that prints only the passed args. But because Eclipse has its own version locked, I needed to download the RCP runtime to a separated target platform and replace the launcher there.
Now I got:

C:\TestEnv>java -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx512m -jar C:\Eclipse36\eclipse\plugins\org.eclipse.equinox.launcher_1. 1.0.v20100507.jar -product TestEnv.product -data C:\Eclipse36\workspace/../runtime-TestEnv.product -configuration file:C:/Eclipse36/workspace/.metadata/.plugins/org.eclipse.p de.core/TestEnv.product/ -dev file:C:/Eclipse36/workspace/.metadata/.plugins/org.eclipse.p de.core/TestEnv.product/dev.properties -os win32 -ws win32 -arch x86 -nl de_DE -consoleLog

So it was the -configuration parameter that was missing.

That leaves me with the question if I could retrieve those parameters at each run programmatically?
Re: Create Batch file to repeat IDE-like launch from external [message #643214 is a reply to message #643201] Mon, 06 December 2010 04:12 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
On Sun, 2010-12-05 at 19:38 -0500, Frank wrote:
> I got the answer to the first question...
>
> I replaced the launcher.jar with an own version that prints only the passed args. But because Eclipse has its own version locked, I needed to download the RCP runtime to a separated target platform and replace the launcher there.
> Now I got:
>
> C:\TestEnv>java -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx512m -jar C:\Eclipse36\eclipse\plugins\org.eclipse.equinox.launcher_1. 1.0.v20100507.jar -product TestEnv.product -data C:\Eclipse36\workspace/../runtime-TestEnv..product -configuration file:C:/Eclipse36/workspace/.metadata/.plugins/org..eclipse. p de.core/TestEnv.product/ -dev file:C:/Eclipse36/workspace/.metadata/.plugins/org.eclipse.p de.core/TestEnv.product/dev.properties -os win32 -ws win32 -arch x86 -nl de_DE -consoleLog
>
> So it was the -configuration parameter that was missing.
>
> That leaves me with the question if I could retrieve those parameters at each run programmatically?

Its much easier to right click on a launch in the Eclipse Debug view.
You then select properties, it shows you the command line used to invoke
the application.
Re: Re: Create Batch file to repeat IDE-like launch from external [message #643254 is a reply to message #643201] Mon, 06 December 2010 09:38 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 423
Registered: July 2009
Senior Member
Hi Frank,

do you mean Platform.getApplicationArgs()?


--

Best Regards,
Wim Jongman

> I got the answer to the first question...
>
> I replaced the launcher.jar with an own version that prints only the passed
args. But because Eclipse has its own version locked, I needed to download
the RCP runtime to a separated target platform and replace the launcher
there.
> Now I got:
>
> C:\TestEnv>java -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx512m -jar
C:\Eclipse36\eclipse\plugins\org.eclipse.equinox.launcher_1.
1.0.v20100507.jar -product TestEnv.product -data
C:\Eclipse36\workspace/../runtime-TestEnv.product -configuration
file:C:/Eclipse36/workspace/.metadata/.plugins/org.eclipse.p
de.core/TestEnv.product/ -dev
file:C:/Eclipse36/workspace/.metadata/.plugins/org.eclipse.p
de.core/TestEnv.product/dev.properties -os win32 -ws win32 -arch x86 -nl
de_DE -consoleLog
>
> So it was the -configuration parameter that was missing.
>
> That leaves me with the question if I could retrieve those parameters at
each run programmatically?
Re: Re: Create Batch file to repeat IDE-like launch from external [message #643261 is a reply to message #643254] Mon, 06 December 2010 10:06 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 179
Registered: July 2009
Senior Member
The debug solution in fact is much easier Very Happy
But, unfortunately still manually.

With Platform.getApplicationArgs() I can only get the args that are not consumed by the RCP framework.

I fact I want to get the complete command line that is generated from the Run-Dialog, so that I write a batch file, that i can than call from outside.

So a user can SVN-checkout the project, start eclipse (building), start the app at least once (it creates the batch file from its own call) and from now on, the external environment is able to start the RCP app with all parameter set right.

Re: Re: Re: Create Batch file to repeat IDE-like launch from external [message #643290 is a reply to message #643261] Mon, 06 December 2010 11:45 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 423
Registered: July 2009
Senior Member
Hi Frank,

I see. There is a solution for that. If you go to your launch configuration,
there is a "Common" tab. In here you can save the launch configuration to a
local file in your project. The user can rightclick that and launch it.

--

Best Regards,
Wim Jongman

> The debug solution in fact is much easier :d
> But, unfortunately still manually.
>
> With Platform.getApplicationArgs() I can only get the args that are not
consumed by the RCP framework.
>
> I fact I want to get the complete command line that is generated from the
Run-Dialog, so that I write a batch file, that i can than call from outside.
>
> So a user can SVN-checkout the project, start eclipse (building), start the
app at least once (it creates the batch file from its own call) and from now
on, the external environment is able to start the RCP app with all parameter
set right.
Re: Create Batch file to repeat IDE-like launch from external [message #643311 is a reply to message #643261] Mon, 06 December 2010 13:17 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Frank wrote:
> The debug solution in fact is much easier :d But, unfortunately still
> manually.

I thought you wanted to know how eclipse launched your RCP app, so you
could write that command line into a batch file and repeat it? That's
what David is suggesting (run it once, and you will get the entire
command like eclipse used to launch your application). Why do you think
that doesn't work?

PW



--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Create Batch file to repeat IDE-like launch from external [message #643413 is a reply to message #643311] Mon, 06 December 2010 19:06 Go to previous messageGo to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 179
Registered: July 2009
Senior Member
This is working "manually" and helps me alot.
With that, I get my application running.

The last thing - to have it perfect - would be, to get this complete command line from the running application itself, so it can recreate that batch file if it was copied onto a coworker's PC with different paths.


Re: Create Batch file to repeat IDE-like launch from external [message #643427 is a reply to message #643413] Mon, 06 December 2010 19:55 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Frank wrote:
> This is working "manually" and helps me alot.
> With that, I get my application running.
>
> The last thing - to have it perfect - would be, to get this complete
> command line from the running application itself, so it can recreate
> that batch file if it was copied onto a coworker's PC with different paths.

There's more to launching an RCP app from your workspace then a simple
command line. You can only create a command line like that after your
local eclipse has launched the app at least once, as Eclipse app
launching contribution creates a configuration area, "development"
properties that contain bundle classpath overrides for projects in the
workspace, etc.

But as mentioned you can share the launch config itself. You'd probably
have to dig into Platform/Debug API to have the first launch generate a
batch file with the full command line.

Just FYI: org.eclipse.core.runtime.Platform.getCommandLineArgs()
mentions org.eclipse.osgi.service.environment.EnvironmentInfo, which
lists framework args as well as command line args.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Create Batch file to repeat IDE-like launch from external [message #643469 is a reply to message #643427] Tue, 07 December 2010 00:08 Go to previous message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 179
Registered: July 2009
Senior Member
Thanks, now it is perfect.

To summarize for anyone interested in this...
1. System property "java.home" to get the jre and java.exe
2. ManagementFactory.getRuntimeMXBean() to get the VM args
3. System property "classplath" to find the path to the launcher
4. Platform.getConfigurationLocation().getURL() for the -configuration arg
5. EnvironmentInfo getCommandLineArgs() for the remaining RCP args
6. Platform.getApplicationArgs() for the remaining appl args

Thanks for all the replies
Previous Topic:Filtering out Run and Debug using Activities
Next Topic:Problems while deploying as product.
Goto Forum:
  


Current Time: Fri Mar 29 01:36:52 GMT 2024

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

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

Back to the top