你可以用nohup ./java.sh ScheduleBashRun &
这样关掉shell窗口进程还在,屏幕输出都append到nohup.out

解决方案 »

  1.   


    > 2、java MyExample start 启动程序;
    > java MyExample stop停止程序。这就像tomcat一样,
    > 但我查不出tomcat是怎样实现的。有个简单(笨?)办法,那就是如楼上的jetercn(heter) 说的那样启动程序,而在java MyExample stop时吐出一个特定的文件,作为所有MyExample进程的停止的命令。当然,要在MyExample监测这个特定的文件的存在。
      

  2.   

    Thank you all very much!But Tomcat doesn't use jetercn or heter, How doesn't tomcat do it?
    I'm really interested in it. I'll test jetercn and heter next Monday. Further more I'll still discuss this problem untill a properlly answer! Thank you!Sorry for my pool English, because my client's machine doesn't have a Chinese input method.
      

  3.   

    当运行 MyExample  start 时启动server,
    server可以监听一个socket, 
    当运行MyExample  stop 时向这个socket发送特定的指令,使原先的server退出,并且自己也退出
      

  4.   

    提供三个线索
    1。CavaJ————类反编译器。
    2。tomcat.bat---tomcat的批处理文件,可以看他的执行过程
    3。jar xvf *.jar解包(tomcat.jar--->org\apache\tomcat\startup)
    我也正在看!
    ================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★  浏览帖子速度极快![建议系统使用ie5.5以上]。 ★  多种帖子实现界面。 
    ★  保存帖子到本地[html格式]★  监视您关注帖子的回复更新。
    ★  可以直接发贴、回复帖子★  采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录! 
    ★  支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名  ●  
         可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
    Http://www.ChinaOK.net/csdn/csdn.rar
    Http://www.ChinaOK.net/csdn/csdn.exe    [自解压]
      

  5.   

    核心代码
    看不懂!!
        public void stopTomcat(InetAddress address, int portInt, String secret)
            throws IOException
        {
            try
            {
                if(address == null)
                {
                    address = InetAddress.getLocalHost();
                }
                Socket socket = new Socket(address, portInt);
                OutputStream os = socket.getOutputStream();
                if(isAjp13)
                {
                    sendAjp13Stop(os, secret);
                } else
                {
                    sendAjp12Stop(os, secret);
                }
                try
                {
                    socket.setSoLinger(true, 0);
                }
                catch(SocketException socketexception) { }
                os.flush();
                os.close();
            }
            catch(IOException ex)
            {
                System.out.println("Error stopping Tomcat with Ajp12 on " + address + ":" + portInt + " " + ex);
            }
        }
      

  6.   

    谢谢各位!
    我将继续查一查,有满意结果后我会用同样的主题公布。
    nohup的测试结果是:
    nohup只是把打印的东西放到nohup.out文件中了,关掉"linux shell(或telnet的dos窗口)"后ScheduleBashRun便停止了。
    运行nohup ./java.sh ScheduleBashRun &
    结果是:
    nohup.out文件内容
    About to schedule task.
    Task scheduled.
    result.txt文件内容为空
      

  7.   

    “zych72(闹闹)”能不能说得更详细点?
    谢谢!
      

  8.   

    刚刚测试了一个HttpServer的例子。
    “zych72(闹闹)”是说明ServerSocket的创建,即要求2、,要求1、仍待解决。