簡體   English   中英

Netbeans Run-> Stop Build不會停止正在運行的Java進程

[英]Netbeans Run->Stop Build does not stop the running java processes

我在Mac OS X Lion 10.7.3上使用Netbeans 7.1.2。

我有一個簡單的Java服務器(使用netty)項目,在構建並運行該項目后,嘗試通過Run-> Stop Build停止運行,它不會終止Java服務器進程。

例如,我的服務器應用程序使用端口8080,甚至在我停止從netbeans運行后,端口8080仍在使用中,並且該應用程序繼續運行。 我必須從活動監視器中手動殺死Java進程。

結束Netbeans啟動的正在運行的應用程序的正確過程是什么?

非常感謝您的幫助。 提前致謝。

看一下文檔: http : //netty.io/docs/stable/guide/html/ 向下滾動到部分9。關閉您的應用程序。

您的主要應用程序看起來像:

package org.jboss.netty.example.time;
public class TimeServer {
    static final ChannelGroup allChannels = new DefaultChannelGroup("time-server"(35));
    public static void main(String[] args) throws Exception {
        ...
        ChannelFactory factory = ...;
        ServerBootstrap bootstrap = ...;
        ...
        Channel channel = bootstrap.bind(...);
        allChannels.add(channel);

        ...

        // Shutdown code
        ChannelGroupFuture future = allChannels.close();
        future.awaitUninterruptibly();
        factory.releaseExternalResources();
    }
}

您的處理程序需要:

public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) {
    TimeServer.allChannels.add(e.getChannel());
}

您必須:1.將所有通道存儲在ChannelGroup .關閉時,關閉所有通道並釋放資源。

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM