Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to deploy SWT/JFace apps?
How to deploy SWT/JFace apps? [message #458596] Sat, 16 July 2005 22:20 Go to next message
Bill is currently offline BillFriend
Messages: 8
Registered: July 2009
Junior Member
***BACKGROUND
In eclipse 3.0.x, we used the File, Export Jar function to make a jar file
of our app. We used a manifest file that specified the main class and had
a Class-Path stmt that specified SWT/JFace support jars. We successfully
deployed those jars in a lib folder beneath the app folder on various
Windows 2000 and XP machines. (We also installed the SWT support DLL,
JDBC drivers and various other support files that probably aren't relevant
to this problem.)

The manifest file looked like this:

Manifest-Version: 1.0
Main-Class: com.companyname.pkgname.etc.MainWindow
Class-Path: lib\swt.jar lib\jface.jar lib\runtime.jar lib\jfacetext.jar
lib\osgi.jar lib\text.jar

(The Class-Path line in the actual file was one line.)

This all worked well.

***NEW SITUATION

Now, with Eclipse 3.1, the above jars are renamed in a better, more
consistent way that includes version numbers. The new file names are
considerably longer - 170 characters total - so fitting them all on one
line may be a concern.

Obviously, we need to restructure our jar building process a bit. We've
done that in too many ways to list here, but would be happy to enumerate,
if asked.

***PROBLEM
1. After days of trying, we can't build a jar file that works. Every jar
we build causes the JVM Launcher to fail with "Could not find main class."


2. When launching on a command line with: java -jar appname.jar
the error message is:

Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/jface/window/ApplicationWindow
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass
(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268 )
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )

(The above is a test of a stripped down app. It's a blank JFace
ApplicationWindow and nothing else. This was to make sure 3rd party libs
weren't the issue)

***QUESTIONS

1. Any thoughts on what's wrong here?

2. Is the list of libraries to support SWT and JFace different with 3.1?

3. With Eclipse 3.1, has anyone succeeded in using File, Export Jar to
make a jar that they simply doubled click on, and it ran in Windows?


TIA, all responses appreciated!
Re: How to deploy SWT/JFace apps? [message #458661 is a reply to message #458596] Mon, 18 July 2005 17:54 Go to previous messageGo to next message
Arun is currently offline ArunFriend
Messages: 61
Registered: July 2009
Member
Hi

Why dont you try creating the jar from the command line itself using the jar
utility.

I had faced a similar problem a few month back.
The jar i created from Eclipse could not be read from a Java program. Turned
out creating the same jar uing the SUN jar utility in your JDK solved the
problem.

Must have been something wrong with the Eclipse jar export functionality.



Arun


"Bill" <bewing@discoverypartners.com> wrote in message
news:d9ec5410290b9a45680b2c9f386940c9$1@www.eclipse.org...
> ***BACKGROUND
> In eclipse 3.0.x, we used the File, Export Jar function to make a jar file
> of our app. We used a manifest file that specified the main class and had
> a Class-Path stmt that specified SWT/JFace support jars. We successfully
> deployed those jars in a lib folder beneath the app folder on various
> Windows 2000 and XP machines. (We also installed the SWT support DLL,
> JDBC drivers and various other support files that probably aren't relevant
> to this problem.)
>
> The manifest file looked like this:
>
> Manifest-Version: 1.0
> Main-Class: com.companyname.pkgname.etc.MainWindow
> Class-Path: lib\swt.jar lib\jface.jar lib\runtime.jar lib\jfacetext.jar
> lib\osgi.jar lib\text.jar
>
> (The Class-Path line in the actual file was one line.)
>
> This all worked well.
>
> ***NEW SITUATION
>
> Now, with Eclipse 3.1, the above jars are renamed in a better, more
> consistent way that includes version numbers. The new file names are
> considerably longer - 170 characters total - so fitting them all on one
> line may be a concern.
>
> Obviously, we need to restructure our jar building process a bit. We've
> done that in too many ways to list here, but would be happy to enumerate,
> if asked.
>
> ***PROBLEM
> 1. After days of trying, we can't build a jar file that works. Every jar
> we build causes the JVM Launcher to fail with "Could not find main class."
>
>
> 2. When launching on a command line with: java -jar appname.jar
> the error message is:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/eclipse/jface/window/ApplicationWindow
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> at java.security.SecureClassLoader.defineClass
> (SecureClassLoader.java:124)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
> at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268 )
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319 )
>
> (The above is a test of a stripped down app. It's a blank JFace
> ApplicationWindow and nothing else. This was to make sure 3rd party libs
> weren't the issue)
>
> ***QUESTIONS
>
> 1. Any thoughts on what's wrong here?
>
> 2. Is the list of libraries to support SWT and JFace different with 3.1?
>
> 3. With Eclipse 3.1, has anyone succeeded in using File, Export Jar to
> make a jar that they simply doubled click on, and it ran in Windows?
>
>
> TIA, all responses appreciated!
>
Re: How to deploy SWT/JFace apps? [message #458759 is a reply to message #458661] Wed, 20 July 2005 20:53 Go to previous messageGo to next message
Bill is currently offline BillFriend
Messages: 8
Registered: July 2009
Junior Member
It is very disappointing that none of the eclipse experts could answer
this question. This newbie found the answer. A detailed procedure is
provided below.

Quick summary:
1. I reported a bug in Eclipse 3.1's "File, Export, Jar file" function.
If it's not a bug, it's a certainly nonrobust, fussy, undiagnosed and a
pitfall: extra white space in the Main-Class line of a manifest file can
result in the main class not being found when trying to run a jar file.
See Bugzilla Bug 104525.

2. The SWT/Jar files needed to run the simplest SWT/Jar apps were
determined experiementally to be:
org.eclipse.swt.win32.win32.x86_3.1.0.jar
org.eclipse.swt_3.1.0.jar
org.eclipse.jface_3.1.0.jar
org.eclipse.core.runtime_3.1.0.jar

3. Based on experience with building apps in Eclipse 3.0.x, I would expect
the following jars to be needed for more complex JFace apps:
org.eclipse.osgi_3.1.0.jar
org.eclipse.jface.text_3.1.0.jar
org.eclipse.text_3.1.0.jar
It sure would be nice to find some overview explanation of these.

4. One of the disturbing things about this is that with 3.0.x, we did not
need to ship any anything like
"org.eclipse.swt.win32.win32.x86_3.1.0.jar". Since this does indeed seem
necessary to shipping JFace 3.1.0 apps, getting some clues about this sure
would've made the transition from 3.0.2 to 3.1.0 easier. The new and
noteworthy pages are a breezy summary, but hardly rigorous or world class
documentation.

================================

The following represents the kind of help I wish I could've found in this
forum or in eclipse documentation instead of learning it all the hard way.
Hopefully this will help other newcomers.

The first two steps refer to using the GUI designer from SWT-Designer.com.


This procedure is intended for win32 environments, but may have some
usefulness for others.

---------------------

JFace App Building and Deployment Demo and Recommended Guidelines for
Win32 Environment

1. From the File menu, select New, Project, Designer, SWT/JFace Java
Project.

2. From the File menu, select New, Other, Designer, JFace
ApplicationWindow. Name this class MainWindow.

3. Make sure the above runs.

4. Under your project's folder, create a folder named lib.

5. In the lib folder put the following files, all of which can be found in
the {ECLIPSE}\plugins folder:
org.eclipse.swt.win32.win32.x86_3.1.0.jar
org.eclipse.swt_3.1.0.jar
org.eclipse.jface_3.1.0.jar
org.eclipse.core.runtime_3.1.0.jar

6. In the project folder, create a file named manifest.txt. Make it look
like this:
Manifest-Version: 1.0
Main-Class: MainWindow
Class-Path: lib\org.eclipse.swt.win32.win32.x86_3.1.0.jar
lib\org.eclipse.swt_3.1.0.jar lib\org.eclipse.jface_3.1.0.jar
lib\org.eclipse.core.runtime_3.1.0.jar

7. Make sure the above Class-Path line is just one (long) line! Including
additional Class-Path lines seems to result in all but the last one
getting ignored.

8. The libs included in the lib and the Class-Path statement were
empirically determined to be the minimum required for this simplistic
JFace demo app. As your app grows, expect other libraries to be needed.
These may include:
org.eclipse.osgi_3.1.0.jar
org.eclipse.jface.text_3.1.0.jar
org.eclipse.text_3.1.0.jar

And, you may also want to add 3rd party libs like jdom.jar, JDBC database
drivers, etc. The max allowed length of the Class-Path line is unknown by
this developer and is an obvious concern, especially now that eclipse.org
greatly lengthened the names of these libs! If anyone determines this max
length, please report it back here.

9. In the Main-Class line above, make sure there is no extra white space
following the name of the class! This has been reported as an eclipse bug
which will cause the JVM launcher to not find it and fail. Also, notice
this demo uses the "default package" which is not a recommended practice
for real apps. Better would be to organize your app into packages. For
example, com.yourdomain.appname.gui.MainWindow. All of that would need to
be spelled out in the Main-Class line. In general, assume the processing
of the manifest file is archaicly picky and unrobust. Make sure
capitalization, syntax, etc. is as shown above.

10. Locate the SWT support DLL for eclipse 3.1: swt-win32-3138.dll. This
can be found in
C:\eclipse\configuration\org.eclipse.osgi\bundles\63\1\.cp. To do
anything in eclipse, you or somebody else probably already had to install
this somewhere. This document recommends you also put it in your project
folder so you can test that exact copy with your app, back it up easily
with your app, and so you don't forget to deploy it. You might even
consider putting this only in each project's folder so you don't have the
dll hell uncertainty of multiple copies of dll's all over the place.

11. In Eclipse, from the File menu, select Export, Jar file. Select Next
to enter the Jar Package Specification dialog.

12. Put checkmarks only in the following:
The src folder for your project.
Export generated class files and resources
Compress the contents of the JAR file

13. Click on Browse to define a jar file name and location for your app.
Appname.jar located in your project's folder is suggested.

14. Click Next to enter the JAR Packaging Options screen. Choose options
you want. Don't forget to put a check mark in Export class files with
warnings if you have any warnings, which are easy enough to get,
especially with the 1.5 jdk and 5.0 compliance.

15. Click on Next to enter the JAR Manifest Specification screen.

16. Select Use existing manifest from workspace. Browse to select the
manifext.txt file prepared above.

17. Click on Finish.

18. In Windows Explorer (not eclipse), double click on the jar file. It
should run. If a "Could not find main class..." message box appears, it
doesn't necessarily mean your main class (MainWindow) is missing, it just
means something in general is wrong. Chances are what really happened is
it did find your MainWindow class (and the obligatory public static void
main(String args[]) method within it), but some dependent class thwarted
proper loading.

19. Troubleshooting. All jar files are really just zip files. Examine the
contents of your jar file using WinZip. The manifest.mf file in there
should look like the manifest.txt you provided above. You should see your
MainWindow.class in there.

20. Another way to test your jar file is to run it via java. In a command
window or batch file, run this:
java -jar appname.jar
The nice thing about this is that it will give you slightly better
information if it fails and you can use parameters to set the amount of
memory the JVM gets, etc.
Notice also the -cp parameter as another way of specifying class path. For
a quick list of parameters, simply type java and hit enter.

21. Deployment. After making sure your jar file runs, deploy as follows:
a. Put jar file and swt-win32-3138.dll in target folder. Alternatively,
put the dll in system32 or somewhere else on the PATH.
b. Put lib folder beneath the above.
c. Create icon to run jar file. By default, windows maps jar files to the
JVM launcher, but the java command line mentioned above has its
advantages.

22. Use of CLASSPATH environment variable. Since this is global to the
target system and can be updated by anybody's installer/app, this
developer is recommending against using or depending on this. If you used
it and then another app came along and updated it, your specs within it
may get pushed to back of the line and guess who gets a phone call at 3:00
am? Getting CLASSPATH stripped down to as little as possible or nothing at
all is offered for consideration.
Re: How to deploy SWT/JFace apps? [message #458765 is a reply to message #458759] Wed, 20 July 2005 23:04 Go to previous messageGo to next message
Bill is currently offline BillFriend
Messages: 8
Registered: July 2009
Junior Member
Wow, it was bad enough that text formatting got stripped, but now I see
the line breaks in my previous post got stripped out too. Was there
something I could have done to prevent this?

If anyone needs help with this topic, they can find a nicely formatted
version of this posting on the SWT-Designer forum located at
www.swt-designer.com.
Re: How to deploy SWT/JFace apps? [message #458789 is a reply to message #458765] Thu, 21 July 2005 13:28 Go to previous message
John is currently offline JohnFriend
Messages: 52
Registered: July 2009
Member
I also had this problem and I found a document that described how to very
well.
I did not have luck using your example.
http://www.cs.umanitoba.ca/~eclipse/1-Install.pdf
Previous Topic:PocketPC and SWT - how to get started - bad major version error
Next Topic:Table within a Table?
Goto Forum:
  


Current Time: Wed Oct 28 02:16:57 GMT 2020

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

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

Back to the top