Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Java program from Eclipse Builders

Tags:

java

eclipse

I want to run a Java program as a builder before the Java Builder kicks in. The Java class to be run is part of another project within the workspace.

I can add Program builder but I don't want to point explicitly to a Java VM as my teammates may have their Java installed in different location. Is there a way to achieve this without referring to a particular JVM executable?

EDIT: Added screenshot of Eclipse Builders to show which config I'm talking about. Screenshot of Eclipse Builders configuration

like image 985
hawk Avatar asked Aug 16 '26 05:08

hawk


1 Answers

I can run the java program using a normal launcher (.launch file created using Run/Debug Configuration). I figured out a way to make that work as a Builder step.

Simply move the .launch to .externalToolBuilders and modify the .project file in a text editor to pick up that .launch file.

<buildCommand>
    <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
    <triggers>full,incremental,</triggers>
    <arguments>
    <dictionary>
        <key>LaunchConfigHandle</key>
        <value>&lt;project&gt;/.externalToolBuilders/MyCustomJavaProgram.launch</value>
    </dictionary>
    </arguments>
</buildCommand>

Eclipse being the good boy it is, doesn't complain about the presence of a org.eclipse.jdt.launching.localJavaApplication as a Builder step and everything works smoothly. In fact if you edit this newly added Builder step it even shows the correct Edit launch configuration dialog.

like image 143
hawk Avatar answered Aug 17 '26 18:08

hawk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!