现在再写一个程序,起重要调用另一个 *.jar 里面的东西,A class, 用了之后会自动生成一个 *.java 文件,我要多次用到这个 *.jar 里面的东西 A calss,也就是说,或生成多个 *.java 文件A class不能更改,每次生成的文件都在 Eclipse 中的工程目录下面,我想把这些生成的文件放在一个地方,怎么做呢?可不可以通过Runtime这个东西来做呢?下面是 javac 的一个例子,大家能帮我想想 java 这个命令的例子么
另外,如果大家有什么好的办法,我也很欢迎
Runtime rt = Runtime.getRuntime();
// current path ./*.java
String command = "javac";
String clsPath1 = " -classpath ./lib/JSHOP2/JSHOP2.jar";
String desPath1 = " -d ./" + "DP";
String srcFile1 = " ./" + "DP/" + "d.java";
try {
// <!!NOTE!!>
// ORDER IS SENSITIVE, the destination is first, then
// it is classpath
// and make sure the srcFile1 and srcFile2 have the same destination
// 2010-2-7
rt.exec.exec(command, envp, dir)
// rt.exec( command + desPath1 + clsPath1 + srcFile1 );
另外,如果大家有什么好的办法,我也很欢迎
Runtime rt = Runtime.getRuntime();
// current path ./*.java
String command = "javac";
String clsPath1 = " -classpath ./lib/JSHOP2/JSHOP2.jar";
String desPath1 = " -d ./" + "DP";
String srcFile1 = " ./" + "DP/" + "d.java";
try {
// <!!NOTE!!>
// ORDER IS SENSITIVE, the destination is first, then
// it is classpath
// and make sure the srcFile1 and srcFile2 have the same destination
// 2010-2-7
rt.exec.exec(command, envp, dir)
// rt.exec( command + desPath1 + clsPath1 + srcFile1 );
只是当我们多次用到A.class的时候没有多次生成*.java吧?
在执行 java A name方法的时候 你在name 前面加个 ./file/name
这个形式看看是不是还有这个情况发生
既然传进去的参数不能改变.class文件的生成目录
那么腻还是把 A.class 的代码贴出来 看看吧