Skip to main content

Thread: Java won't run outside Eclipse - ClassNotFound


is there complicated terminal based annoyance need go through java working terminal? when run programme within eclipse runs fine, when run terminal says this:

code:
go: ls regextest.class go: java regextest.class exception in thread "main" java.lang.noclassdeffounderror: regextest/class caused by: java.lang.classnotfoundexception: regextest.class     @ java.net.urlclassloader$1.run(urlclassloader.java:200)     @ java.security.accesscontroller.doprivileged(native method)     @ java.net.urlclassloader.findclass(urlclassloader.java:188)     @ java.lang.classloader.loadclass(classloader.java:307)     @ sun.misc.launcher$appclassloader.loadclass(launcher.java:301)     @ java.lang.classloader.loadclass(classloader.java:252)     @ java.lang.classloader.loadclassinternal(classloader.java:320) not find main class: regextest.class.  program exit. go:
what mean classnotfound? it's right there!!!!!

i'm sure there insufficient information here resolve problem, don't know info give. i've got sun java 6 jdk. other info people think might helpful?

here's source code of example (regextest.java) i'm using, can comfirm works you, although have same problem programme. have attached file, reason attachment page keeps timing out.

code:
import java.util.regex.matcher; import java.util.regex.pattern;  public class regextest {     public static void main(string args[]) throws exception     {         //regular expression goes here         string regex = ".";         //string match against goes here         string stringtomatch = "abc123";                  //run test         printmatches(regex, stringtomatch);     }          public static void printmatches(string myregex, string mystringtomatch)     {         //print out we're         system.out.println("regex:\t\t" + myregex);         system.out.println("string:\t\t" + mystringtomatch);         system.out.println("");                  try         {             //create regex             pattern mypattern = pattern.compile(myregex);             matcher mymatcher = mypattern.matcher(mystringtomatch);                          //keep running regex , if there's match print out (and keep count)             int matchescount = 0;             while(mymatcher.find())             {                 system.out.println("match " + (matchescount + 1) + ":\t" + mymatcher.group());                 matchescount++;             }                          //print count of matches found             system.out.println("");             if(matchescount == 1)                 system.out.println("one match");             else                 system.out.println(matchescount + " matches");         }         catch(exception e) //print out what's wrong regex         {             system.out.println(":( looks regex wrong:");             system.out.println("");             system.out.println(e);         }     } }

java uses environment variable called classpath find class files. have @ this article how work it.


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [ubuntu] Java won't run outside Eclipse - ClassNotFound


Ubuntu

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support