Results 1 to 5 of 5
  1. #1
    rayzinnz is offline Member
    Join Date
    Jul 2009
    Posts
    3
    Rep Power
    0

    Question 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

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

  3. #3
    rayzinnz is offline Member
    Join Date
    Jul 2009
    Posts
    3
    Rep Power
    0

    Default

    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?

  4. #4
    rayzinnz is offline Member
    Join Date
    Jul 2009
    Posts
    3
    Rep Power
    0

    Default

    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.

  5. #5
    lada314 is offline Member
    Join Date
    Jul 2009
    Posts
    5
    Rep Power
    0

    Default

    the dot "." means current class path, the ":" stands for a seperator

Similar Threads

  1. Replies: 6
    Last Post: 04-08-2009, 04:05 AM
  2. Java On Linux
    By Natrix in forum New To Java
    Replies: 15
    Last Post: 04-08-2009, 12:31 AM
  3. java installation on linux
    By raghu9198 in forum New To Java
    Replies: 1
    Last Post: 03-22-2009, 05:37 PM
  4. Linux process from java
    By Ed in forum New To Java
    Replies: 2
    Last Post: 07-04-2007, 05:03 AM
  5. Linux and java
    By Alan in forum Advanced Java
    Replies: 2
    Last Post: 05-31-2007, 02:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •