NetBeans平台应用程序 - “主类”

时间:2014-02-05 14:19:55

标签: netbeans platform

在启动NetBeans平台应用程序时,有没有办法设置应该启动哪个类?不幸的是,我不是Netbeans的专家。 我必须处理一个遗留项目。这是一个Netbeans平台应用程序,有几个模块。据我所知,在启动期间,该类将是-let's say' - 主类,它扩展了ModuleInstall。通常这个类的名称是Installer。

我的问题是,我有这个扩展ModuleInstall的Installer类,它实现了所有必需的方法,但是如果我启动项目,则会出现其他窗口而不是这个窗口。

你知道我该怎么做才能在开始时调用正确的类吗?

提前致谢!

>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:\bakcsa\app\Java\jdk1.7.0_25\jre
  System Locale; Encoding = en_US (app); Cp1252
  Home Directory          = C:\Users\bakcsa
  Current Directory       = D:\bakcsa\Projects\NetBeans Projects\Java1.6\app
  User Directory          = D:\bakcsa\Projects\NetBeans Projects\Java1.6\app\build\testuserdir
  Cache Directory         = D:\bakcsa\Projects\NetBeans Projects\Java1.6\app\build\testuserdir\var\cache
  Installation            = D:\bakcsa\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:\bakcsa\app\Java\jdk1.7.0_25\jre\lib\resources.jar;D:\bakcsa\app\Java\jdk1.7.0_25\jre\lib\rt.jar;D:\bakcsa\app\Java\jdk1.7.0_25\jre\lib\sunrsasign.jar;D:\bakcsa\app\Java\jdk1.7.0_25\jre\lib\jsse.jar;D:\bakcsa\app\Java\jdk1.7.0_25\jre\lib\jce.jar;D:\bakcsa\app\Java\jdk1.7.0_25\jre\lib\charsets.jar;D:\bakcsa\app\Java\jdk1.7.0_25\jre\lib\jfr.jar;D:\bakcsa\app\Java\jdk1.7.0_25\jre\classes;D:\bakcsa\app\Java\jdk1.7.0_25\jre\lib\ext\access-bridge-64.jar;D:\bakcsa\app\Java\jdk1.7.0_25\jre\lib\ext\dnsns.jar;D:\bakcsa\app\Java\jdk1.7.0_25\jre\lib\ext\jaccess.jar;D:\bakcsa\app\Java\jdk1.7.0_25\jre\lib\ext\localedata.jar;D:\bakcsa\app\Java\jdk1.7.0_25\jre\lib\ext\sunec.jar;D:\bakcsa\app\Java\jdk1.7.0_25\jre\lib\ext\sunjce_provider.jar;D:\bakcsa\app\Java\jdk1.7.0_25\jre\lib\ext\sunmscapi.jar;D:\bakcsa\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:\bakcsa\app\Java\jdk1.7.0_25\lib\dt.jar;D:\bakcsa\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:\bakcsa\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:\bakcsa\app\Java\jdk1.7.0_25
    -splash:D:\bakcsa\Projects\NetBeans Projects\Java1.6\app\build\testuserdir\var\cache\splash.png
    -Dnetbeans.home=C:\Program Files\NetBeans 7.4\platform
    -Dnetbeans.user=D:\bakcsa\Projects\NetBeans Projects\Java1.6\app\build\testuserdir
    -Dnetbeans.default_userdir_root=
    -XX:+HeapDumpOnOutOfMemoryError
    -XX:HeapDumpPath=D:\bakcsa\Projects\NetBeans Projects\Java1.6\app\build\testuserdir\var\log\heapdump.hprof
    -Dsun.awt.keepWorkingSetOnMinimize=true
    -Dnetbeans.dirs=D:\bakcsa\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)

2 个答案:

答案 0 :(得分:3)

这里是你问题的答案(尽管我看到你以不同的方式解决了它)。

但是,我想回答你的问题:

  

有没有办法设置我启动时应该启动哪个类   NetBeans平台应用程序?

是的,有。您可以为NetBeans平台应用程序提供自己的main方法类。

通过在启动应用程序时在命令行上提供系统属性netbeans.mainclass来执行此操作。这必须指向您的自定义主类。定义此变量的位置位于应用程序的conf文件中。

一旦您在自定义主服务器中执行了任何您想要执行的操作,就必须将控制权移交给真正的NetBeans主类。

以下是此类自定义主程序的简短示例:

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);
    }
}

很好地解释了here。 (例子来自该链接)

答案 1 :(得分:1)

  1. Ctrl-1 打开项目窗口
  2. 右键点击项目中的,然后点击属性
  3. 点击左侧类别窗格中的运行节点,在右侧查找主类:文本字段,然后输入主类的完全限定名称,或者您只需单击浏览... 按钮即可避免拼写错误。
  4. enter image description here

    如果是Maven项目,请确保pom.xml元素中的/project/build/plugins包含以下内容:

    <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>