Is there any way to set which class should be started when I start a NetBeans Platform Application? Unfortunately I'm not a Netbeans expert. There is a legacy project I have to deal with. It's a Netbeans Platform App with several modules. As far as I know, during the startup that class will be -let's say'- the main class, which extends ModuleInstall. Usually the name of this class is Installer.
My problem is that, I have this Installer class which extends ModuleInstall, it implements all the required methods, but if I start the project, other window appears instead of this one.
Do you have any idea what should I do to get the proper class invoked at start?
Thanks in advance!
>Log Session: Wednesday, February 5, 2014 3:05:27 PM CET
>System Info:
Product Version = (app) v1.3.3 20138
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.7.0_25; Java HotSpot(TM) 64-Bit Server VM 23.25-b01; Oracle Corporation
Runtime = Java(TM) SE Runtime Environment 1.7.0_25-b16
Java Home = D:\john\app\Java\jdk1.7.0_25\jre
System Locale; Encoding = en_US (app); Cp1252
Home Directory = C:\Users\john
Current Directory = D:\john\Projects\NetBeans Projects\Java1.6\app
User Directory = D:\john\Projects\NetBeans Projects\Java1.6\app\build\testuserdir
Cache Directory = D:\john\Projects\NetBeans Projects\Java1.6\app\build\testuserdir\var\cache
Installation = D:\john\Projects\NetBeans Projects\Java1.6\app\build\cluster
C:\Program Files\NetBeans 7.4\platform
C:\Program Files\NetBeans 7.4\platform
Boot & Ext. Classpath = D:\john\app\Java\jdk1.7.0_25\jre\lib\resources.jar;D:\john\app\Java\jdk1.7.0_25\jre\lib\rt.jar;D:\john\app\Java\jdk1.7.0_25\jre\lib\sunrsasign.jar;D:\john\app\Java\jdk1.7.0_25\jre\lib\jsse.jar;D:\john\app\Java\jdk1.7.0_25\jre\lib\jce.jar;D:\john\app\Java\jdk1.7.0_25\jre\lib\charsets.jar;D:\john\app\Java\jdk1.7.0_25\jre\lib\jfr.jar;D:\john\app\Java\jdk1.7.0_25\jre\classes;D:\john\app\Java\jdk1.7.0_25\jre\lib\ext\access-bridge-64.jar;D:\john\app\Java\jdk1.7.0_25\jre\lib\ext\dnsns.jar;D:\john\app\Java\jdk1.7.0_25\jre\lib\ext\jaccess.jar;D:\john\app\Java\jdk1.7.0_25\jre\lib\ext\localedata.jar;D:\john\app\Java\jdk1.7.0_25\jre\lib\ext\sunec.jar;D:\john\app\Java\jdk1.7.0_25\jre\lib\ext\sunjce_provider.jar;D:\john\app\Java\jdk1.7.0_25\jre\lib\ext\sunmscapi.jar;D:\john\app\Java\jdk1.7.0_25\jre\lib\ext\zipfs.jar
Application Classpath = C:\Program Files\NetBeans 7.4\platform\lib\boot.jar;C:\Program Files\NetBeans 7.4\platform\lib\org-openide-modules.jar;C:\Program Files\NetBeans 7.4\platform\lib\org-openide-util-lookup.jar;C:\Program Files\NetBeans 7.4\platform\lib\org-openide-util.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\boot_ja.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\boot_pt_BR.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\boot_ru.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\boot_zh_CN.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\org-openide-modules_ja.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\org-openide-modules_pt_BR.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\org-openide-modules_ru.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\org-openide-modules_zh_CN.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\org-openide-util-lookup_ja.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\org-openide-util-lookup_pt_BR.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\org-openide-util-lookup_ru.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\org-openide-util-lookup_zh_CN.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\org-openide-util_ja.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\org-openide-util_pt_BR.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\org-openide-util_ru.jar;C:\Program Files\NetBeans 7.4\platform\lib\locale\org-openide-util_zh_CN.jar;D:\john\app\Java\jdk1.7.0_25\lib\dt.jar;D:\john\app\Java\jdk1.7.0_25\lib\tools.jar
Startup Classpath = C:\Program Files\NetBeans 7.4\platform\core\core.jar;C:\Program Files\NetBeans 7.4\platform\core\org-openide-filesystems.jar;C:\Program Files\NetBeans 7.4\platform\core\locale\core_ja.jar;C:\Program Files\NetBeans 7.4\platform\core\locale\core_pt_BR.jar;C:\Program Files\NetBeans 7.4\platform\core\locale\core_ru.jar;C:\Program Files\NetBeans 7.4\platform\core\locale\core_zh_CN.jar;C:\Program Files\NetBeans 7.4\platform\core\locale\org-openide-filesystems_ja.jar;C:\Program Files\NetBeans 7.4\platform\core\locale\org-openide-filesystems_pt_BR.jar;C:\Program Files\NetBeans 7.4\platform\core\locale\org-openide-filesystems_ru.jar;C:\Program Files\NetBeans 7.4\platform\core\locale\org-openide-filesystems_zh_CN.jar;D:\john\Projects\NetBeans Projects\Java1.6\app\build\cluster\core\locale\core_app.jar
-------------------------------------------------------------------------------
INFO [org.netbeans.core.startup.NbEvents]: Turning on modules:
org.openide.util.lookup [8.22.1 201310111528]
org.openide.util [8.33.2 201312091611]
org.openide.modules [7.39.1 201310111528]
org.openide.filesystems [8.8.1 201310111528]
org.netbeans.api.annotations.common/1 [1.21.1 201310111528]
org.openide.awt [7.59.1 201310111528]
org.netbeans.api.progress/1 [1.35.1 201310111528]
org.openide.dialogs [7.32.1 201310111528]
org.openide.nodes [7.36.1 201310111528]
org.openide.windows [6.65.1 201310111528]
org.netbeans.modules.editor.mimelookup/1 [1.33.1 201310111528]
org.openide.text [6.58.2 201312091611]
org.netbeans.swing.tabcontrol [1.46.1 201310111528]
org.netbeans.swing.outline [1.27.1 201310111528]
org.openide.explorer [6.54.1 201312091611]
org.openide.actions [6.32.1 201310111528]
org.netbeans.modules.queries/1 [1.36.1 201310111528]
org.openide.loaders [7.51.1 201310111528]
org.openide.io [1.42.1 201310111528]
org.netbeans.swing.plaf [1.34.1 201310111528]
org.netbeans.spi.quicksearch [1.20.1 201310111528]
org.netbeans.bootstrap/1 [2.63.1 201310111528]
org.netbeans.core.startup/1 [1.51.1 201310111528]
org.netbeans.modules.settings/1 [1.42.1 201310111528]
org.netbeans.modules.sampler [1.7.1 201310111528]
org.netbeans.modules.progress.ui [1.26.1 201310111528]
org.netbeans.modules.print [7.19.1 201310111528]
org.netbeans.modules.keyring [1.17.1 201310111528]
org.netbeans.core/2 [3.43.1 201310111528]
org.netbeans.modules.options.api/1 [1.36.1 201310111528]
org.netbeans.modules.options.keymap [1.28.2 201312091611]
org.netbeans.modules.masterfs/2 [2.44.3 201312091611]
org.netbeans.libs.jna/1 [1.31.1 201310111528]
org.netbeans.modules.masterfs.windows [1.7.1 201310111528]
org.netbeans.modules.keyring.fallback [1.1.1 201310111528]
org.netbeans.modules.keyring.impl [1.14.1 201310111528]
org.netbeans.modules.javahelp/1 [2.34.1 201310111528]
org.netbeans.modules.editor.mimelookup.impl/1 [1.24.1 201310111528]
org.netbeans.libs.osgi [1.15.1 201310111528]
org.netbeans.libs.jna.platform/1 [1.1.1 201310111528]
org.netbeans.libs.felix [2.9.1 201310111528]
org.netbeans.core.windows/2 [2.66.1 201310111528]
org.netbeans.core.ui/1 [1.38.1 201310111528]
org.netbeans.core.output2/1 [1.34.3 201312091611]
org.netbeans.core.network [1.1.2 201312091611]
org.netbeans.core.netigso [1.23.1 201310111528]
org.netbeans.core.nativeaccess/1 [1.23.1 201310111528]
org.netbeans.core.multiview/1 [1.36.1 201310111528]
org.netbeans.core.multitabs [1.3.3.1 1 201310111528]
org.netbeans.core.io.ui/1 [1.23.1 201310111528]
com.awst.lib [1.0 140205]
org.customer.package.name.core.domain [1.0 140205]
org.customer.package.name.core.appexception [1.0 140205]
org.customer.package.name.core.appservices [1.0 140205]
org.customer.package.name.core.datamodel [1.0 140205]
org.customer.package.name.common.userinterface [1.0 140205]
org.customer.package.name.ui.workflow [1.0 140205]
org.customer.package.name.ui.testevaulationreport [1.0 140205]
org.customer.package.name.ui.stationhierarchy [1.0 140205]
org.customer.package.name.ui.datefilter [1.0 140205]
INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy resolver: Windows
INFO [org.netbeans.core.network.proxy.windows.WindowsNetworkProxy]: Windows system proxy resolver: auto detect
INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy reloading succeeded.
INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy - mode: direct
INFO [org.netbeans.core.network.proxy.NetworkProxyReloader]: System network proxy: falled to default (corect if direct mode went before)
WARNING [org.openide.filesystems.Ordering]: Not all children in Toolbars/ marked with the position attribute: [app], but some are: [Memory, Standard.xml]
INFO [org.netbeans.ui.metrics.laf]: USG_LOOK_AND_FEEL
Diagnostic information
Input arguments:
-Dnetbeans.logger.console=true
-ea
-Dlog4j.configuration=org/ctbto/idc/rn/app/core/appservices/log4jconfig.xml
-Xms256m
-Xmx512m
-Xverify:none
-XX:+CMSClassUnloadingEnabled
-Djdk.home=D:\john\app\Java\jdk1.7.0_25
-splash:D:\john\Projects\NetBeans Projects\Java1.6\app\build\testuserdir\var\cache\splash.png
-Dnetbeans.home=C:\Program Files\NetBeans 7.4\platform
-Dnetbeans.user=D:\john\Projects\NetBeans Projects\Java1.6\app\build\testuserdir
-Dnetbeans.default_userdir_root=
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=D:\john\Projects\NetBeans Projects\Java1.6\app\build\testuserdir\var\log\heapdump.hprof
-Dsun.awt.keepWorkingSetOnMinimize=true
-Dnetbeans.dirs=D:\john\Projects\NetBeans Projects\Java1.6\app\build\cluster;C:\Program Files\NetBeans 7.4\platform
exit
Compiler: HotSpot 64-Bit Tiered Compilers
Heap memory usage: initial 256.0MB maximum 455.1MB
Non heap memory usage: initial 23.2MB maximum 130.0MB
Garbage collector: PS Scavenge (Collections=2 Total time spent=0s)
Garbage collector: PS MarkSweep (Collections=0 Total time spent=0s)
Classes: loaded=4107 total loaded=4107 unloaded 0
INFO [org.netbeans.core.ui.warmup.DiagnosticTask]: Total memory 12,866,506,752
INFO [null]: Total physical memory 12,866,506,752
WARNING [org.openide.filesystems.Ordering]: Not all children in Menu/Window/ marked with the position attribute: [org-customer-app-ui-datefilter-DateFilterTopComponent.shadow, org-customer-app-ui-stationhierarchy-StationHierarchyAction.shadow, org-customer-app-ui-testevaulationreport-TestEvaluationReportTopComponent.shadow, org-customer-app-ui-workflow-WorkflowTopComponent.shadow], but some are: [org-netbeans-core-io-ui-IOWindowAction.shadow, SwitchToRecentDocumentAction.shadow, Web, Tools, Separator3.instance, ConfigureWindow, org-netbeans-core-windows-actions-ResetWindowsAction.shadow, Separator4.instance, CloseWindowAction.shadow, CloseAllDocumentsAction.shadow, CloseAllButThisAction.shadow, DocumentsAction.shadow]
WARNING [org.netbeans.TopSecurityManager]: use of system property netbeans.home has been obsoleted in favor of InstalledFileLocator/Places at org.netbeans.Clusters.relativeDirsWithHome(Clusters.java:137)
Here's the answer to your question (although I see you've solved it differently).
However, I would like to answer your question as it stands:
Is there any way to set which class should be started when I start a NetBeans Platform Application?
Yes, there is.You can provide your own main method class to a NetBeans Platform application.
You do this by providing a system property, netbeans.mainclass on the command line when you start your application. This must point to your custom main class. The place to define this variable is in your application's conf file.
Once you're done doing whatever you want to do in your custom main then you must handover control to the real NetBeans main class.
Here's a short example of such a custom main:
public class CustomStartup {
private static final String NB_MAIN_CLASS = "org.netbeans.core.startup.Main";
public static void main(String[] args) throws Exception {
// do whatever you need here (e.g. show a custom login form)
System.out.println("Hello world! I am a custom startup class");
// once you're done with that, hand control back to NetBeans
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
Class<?> mainClass = Class.forName(NB_MAIN_CLASS, true, classloader);
Object mainObject = mainClass.newInstance();
Method mainMethod = mainClass.getDeclaredMethod("main", new Class[]{String[].class});
mainMethod.invoke(mainObject, (Object) args);
}
}
It is quite well explained here. (example is from that link)

If it's a Maven project, make sure the pom.xml has the following w/in the /project/build/plugins element:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass><!--fully qualified name of your main class goes here--></mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With