java 调用erlang模块
werl -sname a Erlang/OTP 18Eshell V7.3(abort with ^G)
(a@LIUXI-L-1)1> erlang:get_cookie().
'XGBXRCHIAJJGKKAJNCWV'
(a@LIUXI-L-1)2> import com.ericsson.otp.erlang.*;
import java.util.*;
class Client
{
public OtpConnection connection;
public static void main(String[] args) throws Exception
{
Client a = new Client("a@LIUXI-L-1","XGBXRCHIAJJGKKAJNCWV");
a.Top(args,args);
}
public Client(String s,String cookie)
{
try
{
OtpSelf self = new OtpSelf("client","client");
OtpPeer other = new OtpPeer(s);
self.setCookie(cookie);
connection = self.connect(other);
}
catch (Exception e)
{
System.out.println(e);
}
}
public String Top(String s,String t) throws Exception
{
connection.sendRPC("erlang","time", new OtpErlangList());
OtpErlangObject received = connection.receiveRPC();
//String arr = received.toString().replace("[","").replace("]","");
String arr = received.toString();
System.out.println("(" + arr + ")");
return "(" + arr + ")";
}
} javac Client.java java Client 123 123
({9,25,31}) 这个{:yxh4:}
个人能力达不到,这么多年来,
还是不知道java是什么样子呢?
页:
[1]