LotusScript中调用Java类

1,创建Java类(另外一个知识点,java库中如果需要用到依赖包,通过,引入“归档”引入jar包)库

public class SayHello { 
	private String username;

	public SayHello(){

	}
		public SayHello(String username){
		this.setUsername(username);
	}

	public void hello(){
		if("".equals(this.username)||null==this.username){
			System.out.println("someOne Says Hello World!");
		}else{
			System.out.println(this.username+" Says Hello World!");
		}
	}

	public void setUsername(String username) {
		this.username = username;
	}
	public String getUsername() {
		return username;
	}
 
}  


2)创建LS库,

在Options,要注明UseLSX"*javacon",还有引用java库 use"java库名"

UseLSX "*javacon"
Use "WorkService"
关键在这里

创建java对象
 Set jSession=New javaSession()
 Set sayHelloClass=jSession.GetClass("SayHello")
 Set helloObject=sayHelloClass.Createobject()
 Call helloObject.hello()
 
另一个例子、

 '创建java对象
 Set jSession=New javaSession()
 Set sayHelloClass=jSession.GetClass("SayHello")
 Set helloObject=sayHelloClass.Createobject("(Ljava/lang/String;)V",userName.Common)	//调用构造函数
 Call helloObject.hello()





你可能感兴趣的:(LotusScript中调用Java类)