How to invoke java task with a different java version than JAVA_HOME?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   david_leal
Posted On:   Friday, September 10, 2004 03:46 AM

I would like to check the result of a suite test class under different jdk versions, without changing the value of the environmente variable JAVA_HOME , in order to execute Ant, with current JDK version, but just testing this class with different jkd versions. Reading the documentation about I don't see any atribute nor nested argument where to set the location of the java executable (you can do with , but I don't see the way to do with ). I have tried to work around this using the task , for example something like this on my target: refid = "run.test.classpath"/> Then invokes ant defining the property ${jdk.exe}    More>>

I would like to check the result of a suite test class under different jdk versions, without changing the value of the environmente variable JAVA_HOME , in order to execute Ant, with current JDK version, but just testing this class with different jkd versions.

Reading the documentation about I don't see any atribute nor nested argument where to set the location of the java executable (you can do with , but I don't see the way to do with ).

I have tried to work around this using the task , for example something like this on my target:

			


refid = "run.test.classpath"/>




Then invokes ant defining the property ${jdk.exe} , for example:

ant -v -Djdk.exe=%JDK_1_3_1% run-UtilSuiteTest



Where %JDK_1_3_1% points to the absolute path of java.exe for the 1.3.1 version. Then I get the following message:
			
run-UtilSuiteTest:
[echo] jdk.exe = C:ARCHIV~1JavaSoftJRE1.3.1_13 injava.exe
[exec] Current OS is Windows 2000
[exec] Executing 'C:ARCHIV~1JavaSoftJRE1.3.1_13 injava.exe -Duser.lan
guage=es -cp P:isfxclass
esources;P:isfxclass;P:isfxlibexternalisfv10.j
ar;P:isfxlibexternaljargs.jar;P:isfxlibexternaljunit.jar isf.util.UtilSu
iteTest' with

BUILD FAILED
P:isfx uild.xml:802: Execute failed: java.io.IOException: CreateProcess: "C:A
RCHIV~1JavaSoftJRE1.3.1_13 injava.exe -Duser.language=es -cp P:isfxclass
resources;P:isfxclass;P:isfxlibexternalisfv10.jar;P:isfxlibexternaljar
gs.jar;P:isfxlibexternaljunit.jar isf.util.UtilSuiteTest" error=123
at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:608)
at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:438)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
at org.apache.tools.ant.Main.runBuild(Main.java:673)
at org.apache.tools.ant.Main.startAnt(Main.java:188)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
Caused by: java.io.IOException: CreateProcess: "C:ARCHIV~1JavaSoftJRE1.3.1_1
3 injava.exe -Duser.language=es -cp P:isfxclass
esources;P:isfxclass;P:i
sfxlibexternalisfv10.jar;P:isfxlibexternaljargs.jar;P:isfxlibexternal
junit.jar isf.util.UtilSuiteTest" error=123
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process. (Win32Process.java:66)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
ute.java:831)
at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:436)
at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:450)
at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:564)
at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:605)
... 11 more
--- Nested Exception ---
java.io.IOException: CreateProcess: "C:ARCHIV~1JavaSoftJRE1.3.1_13 injava.
exe -Duser.language=es -cp P:isfxclass
esources;P:isfxclass;P:isfxlibext
ernalisfv10.jar;P:isfxlibexternaljargs.jar;P:isfxlibexternaljunit.jar i
sf.util.UtilSuiteTest" error=123
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process. (Win32Process.java:66)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
ute.java:831)
at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:436)
at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:450)
at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:564)
at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:605)
at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:438)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
at org.apache.tools.ant.Main.runBuild(Main.java:673)
at org.apache.tools.ant.Main.startAnt(Main.java:188)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)

Total time: 5 seconds
P:isfx>


If I manually execute on the command line window the command to execute it works:
			
P:isfx>C:ARCHIV~1JavaSoftJRE1.3.1_13 injava.exe -Duser.lan
guage=es -cp P:isfxclass
esources;P:isfxclass;P:isfxlibexternalisfv10.j
ar;P:isfxlibexternaljargs.jar;P:isfxlibexternaljunit.jar isf.util.UtilSu
iteTest


Do you have any suggestion about how to do this?



Thanks in advance,



David    <<Less

Re: How to invoke java task with a different java version than JAVA_HOME?

Posted By:   Anonymous  
Posted On:   Monday, September 13, 2004 03:38 AM

Have you tried ?

Re: How to invoke java task with a different java version than JAVA_HOME?

Posted By:   giuseppe_naccarato  
Posted On:   Friday, September 10, 2004 07:43 AM

Hello,
the problem is that while using the exec task with the executable attribute you also pass the parameters. But using 'executable' you can only specify the executable. In order to pass parameters, you have to use nested elements.


See:


http://ant.apache.org/manual/CoreTasks/exec.html


for further details.


Bye

About | Sitemap | Contact