YossiBa
asked on
Executing a java class in izpack installer
Hi,
Do you know how to use Executable tag to execute a java class containing Main() methode?
I need to run a single java class using the izpack.
I tried to insert the class in that tag but didn't compile (in the documentation they note that class is one of the attributes of excecutable tag).
Should I do it in a different way or did I miss some thing?
Please advise
Thanks
Yossi
Do you know how to use Executable tag to execute a java class containing Main() methode?
I need to run a single java class using the izpack.
I tried to insert the class in that tag but didn't compile (in the documentation they note that class is one of the attributes of excecutable tag).
Should I do it in a different way or did I miss some thing?
Please advise
Thanks
Yossi
Looks good, but there don't seem to be any links to a manual on their homepage
be something like:
<executable targetfile="java.exe" args="class to run"/>
<executable targetfile="java.exe" args="class to run"/>
ASKER
Hi,
Thanks for the respond.
Itried the following with no success.
<pack name="class test" required="no">
<description>class test</description>
<executable targetfile="C:\j2sdk1.4.2_ 02\bin\jav a.exe" args="C:\ClassTest.class"/ ></pack>
a simple class that copy files : ClassTest.java:
import java.io.*;
public class ClassTest {
public static void main(String[] args) {
try{
File fs= new File("c:\\BasePath.txt");
File fd= new File("c:\\temp\\test.txt") ;
copy(fs,fd);
}
catch(Exception ex){
}
}
private static void copy(File src, File dst) throws IOException {
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
}
}
After compiling and running using comand prompt it works fine but not using the installer.
Please advise.
Yossi
Thanks for the respond.
Itried the following with no success.
<pack name="class test" required="no">
<description>class test</description>
<executable targetfile="C:\j2sdk1.4.2_
a simple class that copy files : ClassTest.java:
import java.io.*;
public class ClassTest {
public static void main(String[] args) {
try{
File fs= new File("c:\\BasePath.txt");
File fd= new File("c:\\temp\\test.txt")
copy(fs,fd);
}
catch(Exception ex){
}
}
private static void copy(File src, File dst) throws IOException {
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
}
}
After compiling and running using comand prompt it works fine but not using the installer.
Please advise.
Yossi
Where are the online docs?
ASKER
What do you mean about online docs?
> <executable targetfile="C:\j2sdk1.4.2_ 02\bin\jav a.exe" args="C:\ClassTest.class"/ ></pack>
try:
<executable targetfile="C:\j2sdk1.4.2_ 02\bin\jav a.exe" args="ClassTest"/></pack>
try:
<executable targetfile="C:\j2sdk1.4.2_
ASKER
hi,
first, I thank you for your reply.
I tried the following with no success again:
<executable targetfile="C:\j2sdk1.4.2_ 02\java.ex e" stage="postinstall" keep="true" failure="warn">
<args>
<arg value="C:\IzPack\sample\In stall\Inne rClasses\c om\Classes \CopyFile2 "/>
</args>
</executable>
I got an error=2 msgbox.
please advise if it can be done.and if so how can I send more args to the main() function?
I succeded doing that with a jar file but I prefer to simplify that as you advised.
Thanks
Yossi
first, I thank you for your reply.
I tried the following with no success again:
<executable targetfile="C:\j2sdk1.4.2_
<args>
<arg value="C:\IzPack\sample\In
</args>
</executable>
I got an error=2 msgbox.
please advise if it can be done.and if so how can I send more args to the main() function?
I succeded doing that with a jar file but I prefer to simplify that as you advised.
Thanks
Yossi
> I tried the following with no success again:
did u try what i suggested above?
> and if so how can I send more args to the main() function
try including all the args in the args parameter
<executable targetfile="C:\j2sdk1.4.2_ 02\bin\jav a.exe" args="ClassTest param1 param2"/></pack>
did u try what i suggested above?
> and if so how can I send more args to the main() function
try including all the args in the args parameter
<executable targetfile="C:\j2sdk1.4.2_
ASKER
Hi,
Yes I have tried many ways ex:
<executable targetfile="C:\j2sdk1.4.2_ 02\java.ex e" args="C:\IzPack\sample\Ins tall\Inner Classes\co m\Classes\ CopyFile2" keep="true" failure="warn"/>
And
<executable targetfile="C:\j2sdk1.4.2_ 02\java.ex e" args="CopyFile2" keep="true" failure="warn"/>
(by the way, if I do as above how the installer will know where the class located?)
I tested the class using >java CopyFile2
And it works.
CopyFile2 is idetical to ClassTest above.
Please advise....
Thanks a bunch for your help.
Yossi
Yes I have tried many ways ex:
<executable targetfile="C:\j2sdk1.4.2_
And
<executable targetfile="C:\j2sdk1.4.2_
(by the way, if I do as above how the installer will know where the class located?)
I tested the class using >java CopyFile2
And it works.
CopyFile2 is idetical to ClassTest above.
Please advise....
Thanks a bunch for your help.
Yossi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well, Using your solution doesn't work still.
I am more then glad to give you the points though ,You have helped me in the past and I appriciate you're helping me now.
What do I do wrong here? Should I specify a package in the class itself?
If youre not giving up on me I will wait for your help.
Again thanks
Yossi
I am more then glad to give you the points though ,You have helped me in the past and I appriciate you're helping me now.
What do I do wrong here? Should I specify a package in the class itself?
If youre not giving up on me I will wait for your help.
Again thanks
Yossi
ASKER
Mybe there should be a way to activate the main()?