Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NetBeans and Eclipse-like "run configurations"

Is it possible to create anything similar to Eclipse's "run configurations" in NetBeans? I am working on a huge project which is currently not divided into any subprojects in Eclipse. There are in fact many applications in the project which have their own main-methods and separate classpaths. I know, it's a mess.

I'm considering about migrating the project to NetBeans. In the long run it would be sensible to create many projects but for now it would be a real life-saver if I could do similar stuff in NetBeans than in Eclipse: create "launchers" which have their own classpaths. Is this possible?

If it's easy to emulate this behaviour with "external" projects, hints about that are welcome as well.

like image 963
auramo Avatar asked Aug 12 '09 19:08

auramo


2 Answers

Don't know if this is of any interests a lot months later: http://wiki.netbeans.org/FaqTwoMainClassesWithArguments

like image 183
Karussell Avatar answered Nov 15 '22 18:11

Karussell


Using Profiles in Maven is close to the Run Configuirations that Eclipse provides but not quite as flexible. So you can define your profile in your POM.xml

<profiles>
    <profile>
        <id>Config1</id>
        <build>
            <plugins>
                <plugin>
                    <!-- create an all-in-one executable jar with maven-shade-plugin bound 
                        to phase:package special handling for spring.handlers/spring.schemas files 
                        to prevent overwriting (maven-shade-plugin joins them to one file) usage: 
                        cd to <project>/target java -jar hello-world-java-1.0-executable.jar spring/batch/job/hello-world-job.xml 
                        helloWorldJob -->
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>1.7</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <filters>
                                    <filter>
                                        <artifact>*:*</artifact>
                                        <excludes>
                                            <exclude>META-INF/*.SF</exclude>
                                            <exclude>META-INF/*.DSA</exclude>
                                            <exclude>META-INF/*.RSA</exclude>
                                        </excludes>
                                    </filter>
                                </filters>
                                <transformers>
                                    <!-- Added this one because of runtime exception - No container 
                                        provider supports the type class org.glassfish.grizzly.http.server.HttpHandler 
                                        see - http://stackoverflow.com/questions/9787265/grizzly-and-jersey-standalone-jar -->
                                    <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                                    <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                        <mainClass>com.myCompany.nexgen.main.Start</mainClass>
                                        <!-- <mainClass>org.springframework.boot.loader.Launcher</mainClass> -->
                                    </transformer>
                                    <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/spring.handlers</resource>
                                    </transformer>
                                    <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/spring.schemas</resource>
                                    </transformer>
                                </transformers>
                                <shadedArtifactAttached>true</shadedArtifactAttached>
                                <!-- configures the suffix name for the executable jar here it will 
                                    be '<project.artifact>-<project.version>-executable.jar' -->
                                <shadedClassifierName>executable</shadedClassifierName>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>myLocalrun</id>
        <build>
            <directory>
                c:\sdev\myDev\myProj
            </directory>
        </build>
    </profile>
</profiles>

Then in the Project Properties click on Run. Your profiles will be listed in the dropdown menu for Configuration:. Here is where you can create the Arguments for each profile listed in the POM.

enter image description here

This is not a complete answer to the issue. Clearly NetBeans is lacking in the capability to quickly and easily switch between run configurations within the IDE and have those configurations be independent of the build tool and external to the repository. I attach to different databases and use different input configurations based on which aspect of the project I'm working on. This is very limiting in NetBeans. I don't want all my run configurations checked into the repository which is what will happen with the profiles being added to the project POM.

[EDIT]: So I was almost there with the answer above. Clicking on the Customize... button you can now select

Keep private to this IDE instance

enter image description here and now this profile/configuration will NOT be stored in the POM. In fact it is stored in the Project Files - nb-configuration.xml.

enter image description here

like image 23
Nelda.techspiress Avatar answered Nov 15 '22 16:11

Nelda.techspiress