variable java_Java Environment.Variable方法代码示例

import org.apache.tools.ant.types.Environment; //导入方法依赖的package包/类

/**

* Helper method invoked by execute() for each websphere jar to be built.

* Encapsulates the logic of constructing a java task for calling

* websphere.ejbdeploy and executing it.

*

* @param sourceJar java.io.File representing the source (EJB1.1) jarfile.

* @param destJar java.io.File representing the destination, websphere

* jarfile.

*/

private void buildWebsphereJar(File sourceJar, File destJar) {

try {

if (ejbdeploy) {

Java javaTask = new Java(getTask());

// Set the JvmArgs

javaTask.createJvmarg().setValue("-Xms64m");

javaTask.createJvmarg().setValue("-Xmx128m");

// Set the Environment variable

Environment.Variable var = new Environment.Variable();

var.setKey("websphere.lib.dir");

File libdir = new File(websphereHome, "lib");

var.setValue(libdir.getAbsolutePath());

javaTask.addSysproperty(var);

// Set the working directory

javaTask.setDir(websphereHome);

// Set the Java class name

javaTask.setTaskName("ejbdeploy");

javaTask.setClassname("com.ibm.etools.ejbdeploy.EJBDeploy");

javaTask.createArg().setValue(sourceJar.getPath());

javaTask.createArg().setValue(tempdir);

javaTask.createArg().setValue(destJar.getPath());

javaTask.createArg().setLine(getOptions());

if (getCombinedClasspath() != null

&& getCombinedClasspath().toString().length() > 0) {

javaTask.createArg().setValue("-cp");

javaTask.createArg().setValue(getCombinedClasspath().toString());

}

Path classpath = wasClasspath;

if (classpath == null) {

classpath = getCombinedClasspath();

}

javaTask.setFork(true);

if (classpath != null) {

javaTask.setClasspath(classpath);

}

log("Calling websphere.ejbdeploy for " + sourceJar.toString(),

Project.MSG_VERBOSE);

javaTask.execute();

}

} catch (Exception e) {

// Have to catch this because of the semantics of calling main()

throw new BuildException(

"Exception while calling ejbdeploy. Details: " + e.toString(),

e);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值