Jaikiran Pai wrote:If there are no exceptions, are you checking for something else which shows that the server did not stop? Have you tried debugging the code?
I make a mistake, it can stop, but the next time boot up the web application, there are some exception, it seem I should unregisterMBean and UnicastRemoteObject.unexportObject(registry, false);
is there any example about close JMX?
the two java program run on the same machine which OS is unix
I just know socket can communicate,
does java has some ways like unix communicate on the same machine???
/*******************************************************************************
* $Header$
* $Revision$
* $Date$
* TestResource.java
*
*
* Copyright (c) 2001-2006 Primeton Technologies, Ltd.
* All rights reserved.
*
* Created on 2009-11-27
*******************************************************************************/
package com.eshore.itsm.agent.test;
import java.io.File;
import java.io.IOException;
import com.ibatis.common.resources.Resources;
/**
*
* @author Butcher
*/
public class TestResource {
/**
*@param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
final String resource = "com/eshore/itsm/agent/config/sql-map-ibatis.xml";
try {
System.out.println("TestResource process current path:"+ new File("").getAbsolutePath());
System.out.println("TestResource process begin to read source");
Resources.getResourceAsReader(resource);
System.out.println("TestResource process read source success");
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("TestResource process read source fail");
System.out.println(e.getMessage());
}
}
/**
*
* @author 周海锋
*/
public class TestCallResource {
/**
*@param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
System.out.println("TestCallResource process current path:"+ new File("").getAbsolutePath());
Process child = Runtime.getRuntime().exec("java -cp D:\\MyEclipseWork\\agent\\bin com.eshore.itsm.agent.test.TestResource");
int nRead = 0;
byte[] line = new byte[2048];
InputStream out = child.getInputStream();
System.out.println("TestCallResource begin to read child process");
while((nRead = out.read(line))>0){
String lineMsg = new String(line, 0, nRead);
System.out.println(lineMsg);
}
System.out.println("TestCallResource begin to read child process error stream");
out = child.getErrorStream();
while((nRead = out.read(line))>0){
String lineMsg = new String(line, 0, nRead);
System.out.println(lineMsg);
}
System.out.println("TestCallResource read child process end");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
=============================================================================================================
if I just run com.eshore.itsm.agent.test.TestResource
Resources.getResourceAsReader(resource) can read the source "com/eshore/itsm/agent/config/sql-map-ibatis.xml"
but run com.eshore.itsm.agent.test.TestCallResource
Resources.getResourceAsReader(resource) can not read the source "com/eshore/itsm/agent/config/sql-map-ibatis.xml"
this two java file in the same package
why??
how does Resources.getResourceAsReader(resource) work
thanks a lot
it run in Unix
Runtime.getRuntime().exec() will create child process to excute shell script
and if I kill parent process, the child process will aslo exit
so, does any way to prevent child process exit???
it run in Unix
Runtime.getRuntime().exec() will create child process to excute shell script
and if I kill parent process, the child process will aslo exit
so, does any way to prevent child process exit???