Vihaan Verma
Vihaan Verma

Reputation: 13143

NoClassDefFoundError org/eclipse/swt/SWTError

I m trying to compile an open source software . The build works fine and results into a jar file "five-server.jar". When I try to run this file from cmd , I get these errors.

C:\Users\vickey\code\five-server\dist\main>java -jar five-server.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/SWTError
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.SWTError
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: org.devtcg.five.Main. Program will exit.

any suggestion what is wrong?

Upvotes: 1

Views: 14815

Answers (3)

Wolfgang Fahl
Wolfgang Fahl

Reputation: 15769

The SWT Jar files are platform dependent. See http://www.jarfinder.com/index.php/java/info/org.eclipse.swt.SWTError

e.g. on Windows a suitable jar would be: org.eclipse.swt.win32.win32.x86_3.1.0.jar

or on Mac OS X: swt-macosx-3.0m7.jar

and so on. You might run into call kinds of followup problems if you add this dependency e.g. whether you are using 32bit or 64bit libraries.

It is too bad that these kind of dependency problems show up more often than not these days :-(

Upvotes: 5

Razvan
Razvan

Reputation: 10093

You have to set the classpath so that it includes at least the class org.eclipse.swt.SWTError or the jar containing it:

java -classpath path/to/jar/containing/org.eclipse.swt.SWTError -jar five-server.jar

You should also set the Main-class attribute in the manifest file in the five-server.jar

Upvotes: 1

Related Questions