Results 1 to 5 of 5
- 07-15-2009, 09:44 AM #1
Member
- Join Date
- Jul 2009
- Posts
- 3
- Rep Power
- 0
How do you run a java program in linux?
Hi. I've just written my very first program in java in the eclipse program that comes with Ubuntu. It runs fine in eclipse, but I want to run it without loading up eclipse everytime. I tried installing the jdk, but when I type in "java HelloWorldSWT" in the terminal this message comes up:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Composite
Now I'm new to both linux and java, but it seems to me I need to add the swt commands to the java runtime somehow, only I haven't the foggiest idea how.
Thanks
- 07-15-2009, 04:12 PM #2
Have you seen this? "Hello World!" for Solaris OS and Linux
- 07-15-2009, 11:25 PM #3
Member
- Join Date
- Jul 2009
- Posts
- 3
- Rep Power
- 0
Hi thanks hardwired
OK this was originally compiled with eclipse, so I tried compiling with javac this time and get this error:
"package org.eclipse.swt.events does not exist" because I have got the import statement:
"import org.eclipse.swt.events.*" amoungst others, which leads on to a whole lot of other errors.
I also tried the suggestion in to unset CLASSPATH, to no avail.
In Eclipse I used File/Import/Existing Projects into Workspace, then select the SWT archive to run the SWT commands. But then I need eclipse open to run the program.
So how can utilise the SWT in a javac command?
- 07-15-2009, 11:41 PM #4
Member
- Join Date
- Jul 2009
- Posts
- 3
- Rep Power
- 0
OK got it!
I compile in eclipse, then run with java using this command:
java -classpath "org.eclipse.swt/swt.jar:." HelloWorldSWT
I'm not sure what the ":." is for but it doesn't work without it.
Thanks I originally had difficulty searching in google as I didn't know the lingo.
- 07-17-2009, 08:18 AM #5
Member
- Join Date
- Jul 2009
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
[SOLVED] Windows Linux conflict - TrayIcon image not display in Linux
By Eranga in forum Advanced JavaReplies: 6Last Post: 04-08-2009, 04:05 AM -
Java On Linux
By Natrix in forum New To JavaReplies: 15Last Post: 04-08-2009, 12:31 AM -
java installation on linux
By raghu9198 in forum New To JavaReplies: 1Last Post: 03-22-2009, 05:37 PM -
Linux process from java
By Ed in forum New To JavaReplies: 2Last Post: 07-04-2007, 05:03 AM -
Linux and java
By Alan in forum Advanced JavaReplies: 2Last Post: 05-31-2007, 02:30 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks