Solved

Executing a java class in izpack installer

Posted on 2004-09-19
13
424 Views
Last Modified: 2013-11-23
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
0
Comment
Question by:YossiBa
  • 6
  • 5
  • 2
13 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 12096338
Looks good, but there don't seem to be any links to a manual on their homepage
0
 
LVL 92

Expert Comment

by:objects
ID: 12098081
be something like:

<executable targetfile="java.exe" args="class to run"/>
0
 

Author Comment

by:YossiBa
ID: 12154107
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\java.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
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12154112
Where are the online docs?
0
 

Author Comment

by:YossiBa
ID: 12154129
What do you mean about online docs?
0
 
LVL 92

Expert Comment

by:objects
ID: 12156551
> <executable targetfile="C:\j2sdk1.4.2_02\bin\java.exe" args="C:\ClassTest.class"/></pack>

try:

<executable targetfile="C:\j2sdk1.4.2_02\bin\java.exe" args="ClassTest"/></pack>
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:YossiBa
ID: 12158411
hi,
first, I thank you for your reply.
I tried the following with no success again:

<executable targetfile="C:\j2sdk1.4.2_02\java.exe"  stage="postinstall" keep="true" failure="warn">
 <args>
 <arg   value="C:\IzPack\sample\Install\InnerClasses\com\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
0
 
LVL 92

Expert Comment

by:objects
ID: 12158438
> 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\java.exe" args="ClassTest param1 param2"/></pack>
0
 

Author Comment

by:YossiBa
ID: 12158518
Hi,
Yes I have tried many ways ex:

<executable targetfile="C:\j2sdk1.4.2_02\java.exe" args="C:\IzPack\sample\Install\InnerClasses\com\Classes\CopyFile2" keep="true" failure="warn"/>

And

        <executable targetfile="C:\j2sdk1.4.2_02\java.exe" 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

0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 12158537
> by the way, if I do as above how the installer will know where the class located?

the class will need to have been installed in the user classpath for it to work.
Otherwise you'll need to specify the classpath

<executable targetfile="C:\j2sdk1.4.2_02\java.exe" args="-classpath C:\IzPack\sample\Install\InnerClasses\com\Classes CopyFile2" keep="true" failure="warn"/>
0
 

Author Comment

by:YossiBa
ID: 12158583
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
0
 

Author Comment

by:YossiBa
ID: 12158660
Mybe there should be a way to activate the main()?
0
 
LVL 92

Expert Comment

by:objects
ID: 12165296
May be worth asking on the mailing list:

http://lists.berlios.de/mailman/listinfo/izpack-users
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
topping3 challenge 14 70
How can I do a Massively massive community reviewing-and-grading site? 7 71
eclipse java  build path 6 45
replace a word with other 1 40
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now