Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » ClassNotFoundException
ClassNotFoundException [message #708441] Tue, 02 August 2011 20:19 Go to next message
kthomp271828 is currently offline kthomp271828Friend
Messages: 2
Registered: August 2011
Junior Member
I have been using Eclipse Galileo for some time. Recently, I installed Europa for Java IDE. I wrote a basic program that imported nothing other than some classes from java.io and java.util. When I tried to run the program, I got a ClassNotFoundException error. It is my understanding that this error occurs when a class needed by the compiler is not on the class path. The problem is that I don't understand what isn't specified on the class path (what I need to add) or where those files are located. The Europa stack trace error is below:

Thread [main] (Suspended)	
	ClassNotFoundException(Throwable).<init>(String, Throwable) line: 286	
	ClassNotFoundException(Exception).<init>(String, Throwable) line: not available	
	ClassNotFoundException(ReflectiveOperationException).<init>(String, Throwable) line: not available	
	ClassNotFoundException.<init>(String) line: not available	
	URLClassLoader$1.run() line: not available	
	URLClassLoader$1.run() line: not available	
	AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method]	
	Launcher$ExtClassLoader(URLClassLoader).findClass(String) line: not available	
	Launcher$ExtClassLoader(ClassLoader).loadClass(String, boolean) line: not available	
	Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available	
	Launcher$AppClassLoader.loadClass(String, boolean) line: not available	
	Launcher$AppClassLoader(ClassLoader).loadClass(String) line: not available	
	driver.main(String[]) line: 12	
C:\Program Files\Java\jre7\bin\javaw.exe (Aug 1, 2011 2:23:51 AM)
Re: ClassNotFoundException [message #708455 is a reply to message #708441] Tue, 02 August 2011 20:26 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 02-Aug-11 14:19, kthomp271828 wrote:
> I have been using Eclipse Galileo for some time. Recently, I installed
> Europa for Java IDE. I wrote a basic program that imported nothing other
> than some classes from java.io and java.util. When I tried to run the
> program, I got a ClassNotFoundException error. It is my understanding
> that this error occurs when a class needed by the compiler is not on the
> class path. The problem is that I don't understand what isn't specified
> on the class path (what I need to add) or where those files are located.
> The Europa stack trace error is below:
[snip]

(And you backed up by 2 full releases from Galileo because...? The
present current release is the second since Galileo.)

Include the source code to what appears to be driver.main(). There may
be a clue in there.
Re: ClassNotFoundException [message #708463 is a reply to message #708455] Tue, 02 August 2011 20:48 Go to previous messageGo to next message
kthomp271828 is currently offline kthomp271828Friend
Messages: 2
Registered: August 2011
Junior Member
Oh, maybe it wasn't Galileo (or maybe I was confused when I downloaded Europa). I had to re-install everything recently and went to eclipse.org/downloads to get the Java IDE. For some reason, it took me to Europa as the default download so I assumed it was more recent. I see now that isn't the case.


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class driver {

	public static void main(String[] args) throws IOException {
		double oldError;
		NeuralNetwork myNet = new NeuralNetwork("C:\\Users\\Owner\\Documents\\school\\BU\\big data\\independent study\\class24_set1.txt");
		myNet.trainEpoch();
		/*train the network*/
		do {
			oldError = myNet.getTotalError();
			myNet.trainEpoch();
		} while(myNet.getTotalError() < oldError);
		
		/*get test data*/
		int numEx = myNet.getNumExamples();	//assuming both sets have the same number of examples
		int numIn = myNet.getNumInputs();
		int numOut = myNet.getNumOutputs();
		double[][] data = new double[numEx][numIn];
		FileInputStream fstream;
		fstream = new FileInputStream("C:\\Users\\Owner\\Documents\\school\\BU\\big data\\independent study\\class24_set2.txt");
		DataInputStream in = new DataInputStream(fstream);
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		String line;
		int i = -1;
		int j;
		while((line = br.readLine()) != null) {
			j = 0;
			i++;
			data[i][j] = 1;	//bias effect
			StringTokenizer st = new StringTokenizer(line, ",");
			while(st.hasMoreTokens()) {
				j++;
				switch(j) {
				case 1:
				case 2:
					data[i][j] = 0.8*(Double.parseDouble(st.nextToken())/3)+0.1;
					break;
				case 4:
				case 5:
					data[i][j-1] = 0.8*(Double.parseDouble(st.nextToken())/3)+0.1;
					break;
				case 14:
					data[i][5] = 0.8*(Double.parseDouble(st.nextToken())/3)+0.1;
				}
			}
		}
		in.close();
		
		/*generate class output*/
		int r, k;
		int numHid = myNet.getNumHidden();
		double sum = 0;
		double[][] hidden = new double[numEx][numHid+1];
		double[][] output = new double[numEx][numOut];
		for(r = 0; r < numEx; r++) {
			hidden[r][0] = 1;
			for(k = 0; k <= numHid; k++) { //input layer to hidden layer
				sum = 0;
				for(i = 0; i < numIn; i++)
					sum = sum + myNet.getWeight1(k,i)*data[r][i];
				hidden[r][k] = 1 / (1 + Math.exp(-1*sum));
			}
			sum = 0;								//hidden layer to output layer
			for(j = 0; j < numOut; j++) {
				for(k = 0; k <= numHid; k++)
					sum = sum + myNet.getWeight2(j,k)*hidden[r][k];
				output[r][j] = 1 / (1 + Math.exp(-1*sum));
			}
		}
		for(r = 0; r < numEx; r++) {
			if(output[r][0] > output[r][1])
				System.out.println("2");
			else
				System.out.println("4");
		}
	}
}
Re: ClassNotFoundException [message #708472 is a reply to message #708463] Tue, 02 August 2011 21:06 Go to previous message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 02-Aug-11 14:48, kthomp271828 wrote:
> Oh, maybe it wasn't Galileo (or maybe I was confused when I downloaded
> Europa). I had to re-install everything recently and went to
> eclipse.org/downloads to get the Java IDE. For some reason, it took me
> to Europa as the default download so I assumed it was more recent. I see
> now that isn't the case.
> [snip]
If recent, your download should be Indigo then. That's great.

Okay, a couple of observations...

First, 16 year-old Java practice holds that your class name begin with
an upper-case letter. (This is not your exception.)

Second, you should always subsume your Java class down under a formally
named package. Maybe something like: edu.myschool.cs.exercises (can be
anything you like--this is also not your present exception).

Third, I don't see an import statement defining class NeuralNetwork.
This might be your exception. I'm not certain how the compiler let you
get away with this in the first place or why Eclipse accepted to let you
run it.

Observations 1 and 2 are Java questions that should be answered in your
class, in your book, or in specifically Java forums (like the really
great Java Ranch forums). Observation 3 is probably also a Java
question, but would naturally be asked in this forum as you're running
it in Eclipse and it's unclear why it's crashing.

Someone stronger in Java than I might look at your stack trace and
intuit a better response than I'm giving you. Obviously, it's easier to
diagnose having it in one's own workbench.

Last, did you download and set up a proper JDK in installed JREs? If
it's not clear to you what this is, check out the first half of
http://www.javahotchocolate.com/tutorials/setup-jdk.html. This would
tend to make some of the stack trace clearer in some instances.
Previous Topic:Display image in applet viewer
Next Topic:How do I get CVS working?
Goto Forum:
  


Current Time: Wed Sep 25 20:02:10 GMT 2024

Powered by FUDForum. Page generated in 0.08055 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top