I can't compile my Program.java
from the command line (only in Eclipse).
When I want to compile it with
javac Program.java
"cannot find symbol" errors occur at JUnit classes.
Eclipse has the JUnit classes
in it's plugins, but to compile it on my own I would need to somehow compile my JUnit.jar with the program. How can I do that? It doesn't seem to work with
javac -cp absolutePathTo\JUnitJar Program.java
Or is this problem maybe caused because the JUnit classes
are not implemented in my (nested) new Thread
classes?
C:\Documents and Settings\xxxx\Desktop\eclipse\xxxx\Program\src\da
ta>javac -cp junit-4.10.jar Testworks.java
Program.java:81: package org.junit.runner does not exist
import org.junit.runner.Description;
^
Program.java:82: package org.junit.runner does not exist
import org.junit.runner.JUnitCore;
^
Program.java:83: package org.junit.runner does not exist
import org.junit.runner.Request;
^
Program.java:84: package org.junit.runner does not exist
import org.junit.runner.Result;
^
Program.java:85: package org.junit.runner.notification does not exist
import org.junit.runner.notification.Failure;
^
Program.java:86: package org.junit.runner.notification does not exist
import org.junit.runner.notification.RunListener;
^
Program.java:253: cannot find symbol
symbol : class JUnitCore
location: class data.Program
JUnitCore jCore; //-> Core Runner - has no pleaseStop()
^
Program.java:254: cannot find symbol
symbol : class RunListener
location: class data.Program
RunListener jRl;
^
Program.java:255: cannot find symbol
symbol : class Request
location: class data.Program
Request jRq;
^
Program.java:2167: cannot find symbol
symbol : class RunListener
location: class data.Program
class RlOne extends RunListener{
^
Program.java:2170: cannot find symbol
symbol : class Description
location: class data.Program.RlOne
public void testRunStarted(Description descRun)
^
Program.java:2179: cannot find symbol
symbol : class Description
location: class data.Program.RlOne
public void testStarted(Description descStart)
^
Program.java:2185: cannot find symbol
symbol : class Description
location: class data.Program.RlOne
public void testFinished(Description descFinish)
^
Program.java:2202: cannot find symbol
symbol : class Failure
location: class data.Program.RlOne
public void testFailure(Failure failure)
^
Program.java:2211: cannot find symbol
symbol : class Description
location: class data.Program.RlOne
public void testIgnored(Description descIgno)
^
Program.java:2221: cannot find symbol
symbol : class Result
location: class data.Program.RlOne
public void testRunFinished(Result result)
^
Program.java:2422: cannot find symbol
symbol : variable Request
location: class data.Program.ThirdThread
jRq = Request.aClass(cRun);
^
Program.java:2426: cannot find symbol
symbol : variable Request
location: class data.Program.ThirdThread
jRq = Request.method(cRun, comb_meth.getSelected
Item().toString());
^
Program.java:2584: cannot find symbol
symbol : class JUnitCore
location: class data.Program
jCore = new JUnitCore();
^
19 errors
The java command output when I want to start it by the Eclipse compiled Program.class
:
C:\Documents and Settings\xxxx\Desktop\eclipse\xxxx\Program\bin\da
ta>java Program
Exception in thread "main" java.lang.NoClassDefFoundError: Program
Caused by: java.lang.ClassNotFoundException: Program
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: Program. Program will exit.
Now I got it to work.
I renamed junit-4.10.jar
to junit.jar
, moved it to another folder and somehow this solved the problem:
javac -classpath "C:\Documents and Settings\x\Desktop\eclipse\x\Program\extres\junit.jar" src\data\Program.java
BTW:
When I'm in C:\Documents and Settings\x\Desktop\eclipse\x\Program\
it also works with:
javac -classpath extres\junit.jar src\data\Program.java