Results 1 to 7 of 7

Thread: run a class

  1. #1
    manou2324 is offline Member
    Join Date
    Mar 2013
    Posts
    56
    Rep Power
    0

    Default run a class

    hi;

    Please how can i run ,from another class,the method :
    Java Code:
    public static void main (String [] args) {...}
    of a class named "hello.java" ??

    thank you

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: run a class

    Java Code:
    hello.main(new String[]{});
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    manou2324 is offline Member
    Join Date
    Mar 2013
    Posts
    56
    Rep Power
    0

    Default Re: run a class

    I wrote a class named "Appeler.java" in a project1..it should execute another class "Parseur.java" in a project2.
    Parseur.java contains only a "main" method. It is in a package named "ihm" ans i imported the "parseur.jar" in my project1.
    Here i did what you said but it didn't work:
    Java Code:
    package com.excilys.labs;
    import java.io.IOException;
    import ihm.Parseur;
    
    public class Appeler {
         public static void main(String[] args) throws IOException 
    {   Parseur.main(new String[]{});  }
                                }

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: run a class

    What didn't work? What errors or Exceptions did you get?
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  5. #5
    manou2324 is offline Member
    Join Date
    Mar 2013
    Posts
    56
    Rep Power
    0

    Default Re: run a class

    Quote Originally Posted by PhHein View Post
    What didn't work? What errors or Exceptions did you get?


    Exception in thread "main" java.lang.NoClassDefFoundError: org/htmlparser/util/NodeIterator
    at com.excilys.labs.Appeler.main(Appeler.java:15)
    Caused by: java.lang.ClassNotFoundException: org.htmlparser.util.NodeIterator
    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)
    ... 1 more

  6. #6
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: run a class

    NodeIterator isn't on your classpath. Java doesn't know where to find it.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  7. #7
    manou2324 is offline Member
    Join Date
    Mar 2013
    Posts
    56
    Rep Power
    0

Similar Threads

  1. Replies: 1
    Last Post: 12-13-2012, 04:06 AM
  2. Replies: 1
    Last Post: 11-29-2012, 10:46 AM
  3. Replies: 0
    Last Post: 12-07-2011, 12:55 PM
  4. Replies: 0
    Last Post: 03-27-2011, 06:49 AM
  5. Replies: 5
    Last Post: 01-26-2011, 07:38 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
  •