Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Packaging with SWT
Packaging with SWT [message #455362] Fri, 13 May 2005 00:16 Go to next message
Eclipse UserFriend
Originally posted by: xyzzy.foo.gmail.com

Is there a way to package a program with SWT so that it can be run on a
machine where SWT has not been previously installed and so that the
users do not need to install SWT?

-Matt
Re: Packaging with SWT [message #455370 is a reply to message #455362] Fri, 13 May 2005 05:01 Go to previous messageGo to next message
Eclipse UserFriend
Matt Dordal wrote:
> Is there a way to package a program with SWT so that it can be run on a
> machine where SWT has not been previously installed and so that the
> users do not need to install SWT?
>
> -Matt
Besides adding the swt jars you have to copy the appropriate dll, so,
etc(Depending on your target platform) to the machine and make it
available to your VM via the "-Djava.library.path" property.

Regards
Stefan
Re: Packaging with SWT [message #455409 is a reply to message #455370] Fri, 13 May 2005 10:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: martin.j.nilsson.sverige.nu

> Besides adding the swt jars you have to copy the appropriate dll, so,
> etc(Depending on your target platform) to the machine and make it
> available to your VM via the "-Djava.library.path" property.

Just a side-note; you can easily package the DLL(s) inside your jar and
extract them the first time the application is run. Yes, you will leave a
trace of your application (the dll-file) on your user's hard drive, but
IMHO that is not a big issue. If it is I guess you could remove it when
the program quits (at least if it ended normally and not by a kill -9 or
something), but that means that it would have to be extracted on every
start of the application, not just the first.


regards,
martin
Re: Packaging with SWT [message #455452 is a reply to message #455362] Sat, 14 May 2005 19:01 Go to previous messageGo to next message
Eclipse UserFriend
"Matt Dordal" <xyzzy.foo@gmail.com> wrote in message
news:d61a6i$vdq$1@news.eclipse.org...
> Is there a way to package a program with SWT so that it can be run on a
> machine where SWT has not been previously installed and so that the
> users do not need to install SWT?

You can find source code for self-extracting and implementing jar file
for SWT from the following url. You can figure out how you can
port into your system;

http://www.roselladb.com/freeware/Sej.tar

Note that it's "tar"-red file!


>
> -Matt
Re: Packaging with SWT [message #455453 is a reply to message #455409] Sun, 15 May 2005 01:33 Go to previous messageGo to next message
Eclipse UserFriend
Martin J Nilsson wrote:
> Just a side-note; you can easily package the DLL(s) inside your jar and
> extract them the first time the application is run. Yes, you will leave
> a trace of your application (the dll-file) on your user's hard drive,
> but IMHO that is not a big issue. If it is I guess you could remove it
> when the program quits (at least if it ended normally and not by a kill
> -9 or something), but that means that it would have to be extracted on
> every start of the application, not just the first.
>
>
> regards,
> martin
>
That would seem to be the best. I don't paticularly care if the program
leaves the dll, but I don' want the program to require additional
installation if that can be automated.
How would I set the JAR up to extract the file on the first run?

Thanks,
Matt
Re: Packaging with SWT [message #455455 is a reply to message #455453] Sun, 15 May 2005 01:59 Go to previous messageGo to next message
Eclipse UserFriend
<user@domain.invalid> wrote in message news:d66ngm$se0$1@news.eclipse.org...
> Martin J Nilsson wrote:
> > Just a side-note; you can easily package the DLL(s) inside your jar and
> > extract them the first time the application is run. Yes, you will leave
> > a trace of your application (the dll-file) on your user's hard drive,
> > but IMHO that is not a big issue. If it is I guess you could remove it
> > when the program quits (at least if it ended normally and not by a kill
> > -9 or something), but that means that it would have to be extracted on
> > every start of the application, not just the first.
> >
> >
> > regards,
> > martin
> >
> That would seem to be the best. I don't paticularly care if the program
> leaves the dll, but I don' want the program to require additional
> installation if that can be automated.
> How would I set the JAR up to extract the file on the first run?

The following file has sample codes how you can do it!
Note that it tar archive file.
http://www.roselladb.com/freeware/Sej.tar

Regards,

>
> Thanks,
> Matt
Re: Packaging with SWT [message #455456 is a reply to message #455453] Sun, 15 May 2005 02:15 Go to previous messageGo to next message
Eclipse UserFriend
<user@domain.invalid> wrote in message news:d66ngm$se0$1@news.eclipse.org...
> Martin J Nilsson wrote:
> > Just a side-note; you can easily package the DLL(s) inside your jar and
> > extract them the first time the application is run. Yes, you will leave
> > a trace of your application (the dll-file) on your user's hard drive,
> > but IMHO that is not a big issue. If it is I guess you could remove it
> > when the program quits (at least if it ended normally and not by a kill
> > -9 or something), but that means that it would have to be extracted on
> > every start of the application, not just the first.
> >
> >
> > regards,
> > martin
> >
> That would seem to be the best. I don't paticularly care if the program
> leaves the dll, but I don' want the program to require additional
> installation if that can be automated.
> How would I set the JAR up to extract the file on the first run?
>

Testing SWT implementation is easy;

try {
int k = org.eclipse.swt.SWT.DEFAULT;
// your system is already SWT installed!
} catch (Throwable t) {
// call SWT installation routines
// you may need to restart here. you better test this!
}



> Thanks,
> Matt
Re: Packaging with SWT [message #455462 is a reply to message #455453] Mon, 16 May 2005 04:01 Go to previous message
Eclipse UserFriend
Originally posted by: martin.j.nilsson.sverige.nu

Matt,

This is how I would do it, I'm sure there are multiple ways of improving
this code.

private boolean checkSWTInstallation(String swtDllName) {
File javaHome = new File(System.getProperty("java.home"));
File javaBin = new File(javaHome, "bin");
File swtdllDest = new File(javaBin, swtDllName);

if (!swtdllDest.isFile()) {
try {
InputStream is = getClass().getResourceAsStream("resource/" +
swtDllName);
if (is == null) {
return false;
}
try {
OutputStream os = new FileOutputStream(swtdllDest);
try {
byte[] buf = new byte[4096];
for (;;) {
int actual = is.read(buf);
if (actual <= 0) {
break;
}
os.write(buf, 0, actual);
}
} finally {
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (IOException iox) {
iox.printStackTrace();
return false;
}
}
return true;
}
Previous Topic:MinimizeBox and ControlBox properties for Windows CE forms
Next Topic:Possible to take out the vertical scrollbar for the Browser widget?
Goto Forum:
  


Current Time: Sat Jul 12 23:47:20 EDT 2025

Powered by FUDForum. Page generated in 0.47342 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top