Results 1 to 15 of 15
  1. #1
    kthomp271828 is offline Member
    Join Date
    Aug 2011
    Posts
    17
    Rep Power
    0

    Default ClassNotFoundException - What jar do I need?

    I am trying to run a program from Eclipse but I get the following when I run the debugger:

    Thread [main] (Suspended)
    ClassNotFoundException(Throwable).<init>(String, Throwable) line: 286
    ClassNotFoundException(Exception).<init>(String, Throwable) line: not available
    ClassNotFoundException(ReflectiveOperationExceptio n).<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(PrivilegedExceptionA ction<T>, AccessControlContext) line: not available [native method]
    Launcher$ExtClassLoader(URLClassLoader).findClass( String) line: not available
    Launcher$ExtClassLoader(ClassLoader).loadClass(Str ing, boolean) line: not available
    Launcher$AppClassLoader(ClassLoader).loadClass(Str ing, boolean) line: not available
    Launcher$AppClassLoader.loadClass(String, boolean) line: not available
    Launcher$AppClassLoader(ClassLoader).loadClass(Str ing) line: not available
    driver.main(String[]) line: 12
    C:\Program Files\Java\jre7\bin\javaw.exe (Aug 1, 2011 2:23:51 AM)

    I have read other posts and know that there is some jar file missing from the classpath that is throwing this exception. I just have no idea how to know which jar file and where it is located.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,435
    Rep Power
    25

    Default

    What errors do you get when you execute the program with the java command?

  3. #3
    kthomp271828 is offline Member
    Join Date
    Aug 2011
    Posts
    17
    Rep Power
    0

    Default

    I ran from the command line in Linux and got the following. What does it mean?

    k_thomp@linux-8awa:~/Documents/second_attempt> javac NeuralNetwork.java
    k_thomp@linux-8awa:~/Documents/second_attempt> javac driver.java
    k_thomp@linux-8awa:~/Documents/second_attempt> java driver.class
    Unpacking...
    Checksumming...
    Extracting...
    UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
    creating: jre1.6.0_25/
    creating: jre1.6.0_25/bin/
    inflating: jre1.6.0_25/bin/java
    inflating: jre1.6.0_25/bin/jcontrol
    linking: jre1.6.0_25/bin/ControlPanel -> ./jcontrol
    inflating: jre1.6.0_25/bin/java_vm
    inflating: jre1.6.0_25/bin/javaws
    inflating: jre1.6.0_25/bin/keytool
    inflating: jre1.6.0_25/bin/policytool
    inflating: jre1.6.0_25/bin/rmiregistry
    inflating: jre1.6.0_25/bin/rmid
    inflating: jre1.6.0_25/bin/tnameserv
    inflating: jre1.6.0_25/bin/orbd
    inflating: jre1.6.0_25/bin/servertool
    inflating: jre1.6.0_25/bin/unpack200
    inflating: jre1.6.0_25/bin/pack200
    creating: jre1.6.0_25/lib/
    creating: jre1.6.0_25/lib/applet/
    creating: jre1.6.0_25/lib/ext/
    inflating: jre1.6.0_25/lib/ext/sunjce_provider.jar
    inflating: jre1.6.0_25/lib/ext/sunpkcs11.jar
    inflating: jre1.6.0_25/lib/ext/dnsns.jar
    inflating: jre1.6.0_25/lib/ext/localedata.pack
    inflating: jre1.6.0_25/lib/ext/meta-index
    creating: jre1.6.0_25/lib/i386/
    creating: jre1.6.0_25/lib/i386/native_threads/
    inflating: jre1.6.0_25/lib/i386/native_threads/libhpi.so
    creating: jre1.6.0_25/lib/i386/server/
    inflating: jre1.6.0_25/lib/i386/server/libjvm.so
    inflating: jre1.6.0_25/lib/i386/server/Xusage.txt
    linking: jre1.6.0_25/lib/i386/server/libjsig.so -> ../libjsig.so
    inflating: jre1.6.0_25/lib/i386/libnpjp2.so
    creating: jre1.6.0_25/lib/i386/client/
    inflating: jre1.6.0_25/lib/i386/client/libjvm.so
    inflating: jre1.6.0_25/lib/i386/client/Xusage.txt
    linking: jre1.6.0_25/lib/i386/client/libjsig.so -> ../libjsig.so
    inflating: jre1.6.0_25/lib/i386/libjsig.so
    inflating: jre1.6.0_25/lib/i386/libnative_chmod.so
    inflating: jre1.6.0_25/lib/i386/libnative_chmod_g.so
    inflating: jre1.6.0_25/lib/i386/libverify.so
    inflating: jre1.6.0_25/lib/i386/libjava.so
    creating: jre1.6.0_25/lib/i386/jli/
    inflating: jre1.6.0_25/lib/i386/jli/libjli.so
    inflating: jre1.6.0_25/lib/i386/jvm.cfg
    inflating: jre1.6.0_25/lib/i386/libzip.so
    inflating: jre1.6.0_25/lib/i386/libnpt.so
    inflating: jre1.6.0_25/lib/i386/libjava_crw_demo.so
    inflating: jre1.6.0_25/lib/i386/libhprof.so
    inflating: jre1.6.0_25/lib/i386/libnet.so
    inflating: jre1.6.0_25/lib/i386/libnio.so
    inflating: jre1.6.0_25/lib/i386/libmanagement.so
    inflating: jre1.6.0_25/lib/i386/libinstrument.so
    inflating: jre1.6.0_25/lib/i386/libjsound.so
    inflating: jre1.6.0_25/lib/i386/libjsoundalsa.so
    inflating: jre1.6.0_25/lib/i386/libj2pcsc.so
    inflating: jre1.6.0_25/lib/i386/libj2pkcs11.so
    inflating: jre1.6.0_25/lib/i386/libj2gss.so
    inflating: jre1.6.0_25/lib/i386/libdcpr.so
    inflating: jre1.6.0_25/lib/i386/libmlib_image.so
    inflating: jre1.6.0_25/lib/i386/libawt.so
    inflating: jre1.6.0_25/lib/i386/libsplashscreen.so
    creating: jre1.6.0_25/lib/i386/xawt/
    inflating: jre1.6.0_25/lib/i386/xawt/libmawt.so
    creating: jre1.6.0_25/lib/i386/motif21/
    inflating: jre1.6.0_25/lib/i386/motif21/libmawt.so
    creating: jre1.6.0_25/lib/i386/headless/
    inflating: jre1.6.0_25/lib/i386/headless/libmawt.so
    inflating: jre1.6.0_25/lib/i386/libfontmanager.so
    inflating: jre1.6.0_25/lib/i386/libjpeg.so
    inflating: jre1.6.0_25/lib/i386/libcmm.so
    inflating: jre1.6.0_25/lib/i386/libioser12.so
    inflating: jre1.6.0_25/lib/i386/librmi.so
    inflating: jre1.6.0_25/lib/i386/libJdbcOdbc.so
    inflating: jre1.6.0_25/lib/i386/libjawt.so
    inflating: jre1.6.0_25/lib/i386/libjaas_unix.so
    inflating: jre1.6.0_25/lib/i386/libunpack.so
    inflating: jre1.6.0_25/lib/i386/libdeploy.so
    inflating: jre1.6.0_25/lib/i386/libjdwp.so
    inflating: jre1.6.0_25/lib/i386/libdt_socket.so
    inflating: jre1.6.0_25/lib/i386/libjavaplugin_jni.so
    inflating: jre1.6.0_25/lib/i386/libjavaplugin_nscp.so
    inflating: jre1.6.0_25/lib/i386/libjavaplugin_nscp_gcc29.so
    inflating: jre1.6.0_25/lib/rt.pack
    creating: jre1.6.0_25/lib/security/
    inflating: jre1.6.0_25/lib/security/US_export_policy.jar
    inflating: jre1.6.0_25/lib/security/local_policy.jar
    inflating: jre1.6.0_25/lib/security/java.security
    inflating: jre1.6.0_25/lib/security/java.policy
    inflating: jre1.6.0_25/lib/security/cacerts
    inflating: jre1.6.0_25/lib/security/blacklist
    inflating: jre1.6.0_25/lib/security/trusted.libraries
    inflating: jre1.6.0_25/lib/security/javaws.policy
    inflating: jre1.6.0_25/lib/jce.jar
    creating: jre1.6.0_25/lib/fonts/
    inflating: jre1.6.0_25/lib/fonts/LucidaTypewriterRegular.ttf
    inflating: jre1.6.0_25/lib/fonts/LucidaTypewriterBold.ttf

    etc ...

    inflating: jre1.6.0_25/COPYRIGHT
    extracting: jre1.6.0_25/LICENSE
    inflating: jre1.6.0_25/Welcome.html
    extracting: jre1.6.0_25/THIRDPARTYLICENSEREADME.txt
    extracting: jre1.6.0_25/README
    creating: jre1.6.0_25/man/
    creating: jre1.6.0_25/man/man1/
    inflating: jre1.6.0_25/man/man1/java.1
    inflating: jre1.6.0_25/man/man1/keytool.1
    inflating: jre1.6.0_25/man/man1/rmid.1
    inflating: jre1.6.0_25/man/man1/rmiregistry.1
    inflating: jre1.6.0_25/man/man1/tnameserv.1
    inflating: jre1.6.0_25/man/man1/servertool.1
    inflating: jre1.6.0_25/man/man1/orbd.1
    inflating: jre1.6.0_25/man/man1/policytool.1
    inflating: jre1.6.0_25/man/man1/pack200.1
    inflating: jre1.6.0_25/man/man1/unpack200.1
    inflating: jre1.6.0_25/man/man1/javaws.1
    linking: jre1.6.0_25/man/ja -> ja_JP.eucJP
    creating: jre1.6.0_25/man/ja_JP.eucJP/
    creating: jre1.6.0_25/man/ja_JP.eucJP/man1/
    inflating: jre1.6.0_25/man/ja_JP.eucJP/man1/java.1
    inflating: jre1.6.0_25/man/ja_JP.eucJP/man1/keytool.1
    inflating: jre1.6.0_25/man/ja_JP.eucJP/man1/rmid.1
    inflating: jre1.6.0_25/man/ja_JP.eucJP/man1/rmiregistry.1
    inflating: jre1.6.0_25/man/ja_JP.eucJP/man1/tnameserv.1
    inflating: jre1.6.0_25/man/ja_JP.eucJP/man1/servertool.1
    inflating: jre1.6.0_25/man/ja_JP.eucJP/man1/orbd.1
    inflating: jre1.6.0_25/man/ja_JP.eucJP/man1/policytool.1
    inflating: jre1.6.0_25/man/ja_JP.eucJP/man1/pack200.1
    inflating: jre1.6.0_25/man/ja_JP.eucJP/man1/unpack200.1
    inflating: jre1.6.0_25/man/ja_JP.eucJP/man1/javaws.1
    creating: jre1.6.0_25/plugin/
    creating: jre1.6.0_25/plugin/i386/
    creating: jre1.6.0_25/plugin/i386/ns7/
    inflating: jre1.6.0_25/plugin/i386/ns7/libjavaplugin_oji.so
    creating: jre1.6.0_25/plugin/i386/ns7-gcc29/
    inflating: jre1.6.0_25/plugin/i386/ns7-gcc29/libjavaplugin_oji.so
    creating: jre1.6.0_25/plugin/desktop/
    extracting: jre1.6.0_25/plugin/desktop/sun_java.png
    inflating: jre1.6.0_25/plugin/desktop/sun_java.desktop
    creating: jre1.6.0_25/javaws/
    linking: jre1.6.0_25/javaws/javaws -> ../bin/javaws
    Creating jre1.6.0_25/lib/rt.jar
    Creating jre1.6.0_25/lib/jsse.jar
    Creating jre1.6.0_25/lib/charsets.jar
    Creating jre1.6.0_25/lib/ext/localedata.jar
    Creating jre1.6.0_25/lib/plugin.jar
    Creating jre1.6.0_25/lib/javaws.jar
    Creating jre1.6.0_25/lib/deploy.jar

    Done.

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,435
    Rep Power
    25

    Default

    It looks like the java command successfully executed the program.
    I have no idea what the program is supposed to do.
    From what you posted, it looks like an installer.

  5. #5
    kthomp271828 is offline Member
    Join Date
    Aug 2011
    Posts
    17
    Rep Power
    0

    Default

    The program is a neural network that should spit out the classifications for the input data. Actually, this same output happens each time I try to run any Java program from Linux command line. I think it looks like it is installing Java every time.

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,435
    Rep Power
    25

    Default

    Sorry I'm not familiar with Linux.
    It looks the the java command you are executing is NOT the command installed with the JRE. Can you find the real java command and rename the one you are using out of the way?
    Is this referring to a command:
    inflating: jre1.6.0_25/bin/java

  7. #7
    kthomp271828 is offline Member
    Join Date
    Aug 2011
    Posts
    17
    Rep Power
    0

    Default

    I will try. I am actually not that familiar with Linux either. The first message I posted was from Windows using Eclipse.
    Is this referring to a command:
    inflating: jre1.6.0_25/bin/java
    If you mean is it a command from within my code, no. Also, if it's helpful ... if I try to run the driver class now a second time I get this:

    k_thomp@linux-8awa:~/Documents/second_attempt> java driver
    Unpacking...
    Checksumming...
    Extracting...
    UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
    replace jre1.6.0_25/bin/java? [y]es, [n]o, [A]ll, [N]one, [r]ename:

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,435
    Rep Power
    25

    Default

    Try asking a question on a linux forum about the java command being an installer vs being the JRE's java command.

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default

    Your java command link (which is generally what it is) is pointing to the installer by the look of it.
    Which is clearly not correct.

    do (in a terminal):
    which java
    That will show you what it thinks it is running.
    If that points to the link then go to that directory and see what the link is pointing to:
    ls -l java
    Which will then show you where that link is pointing to.

    ETA: Note I'm working from memory here (which is never a Good Thing) since I don't have a Linux box in front of me.

  10. #10
    kthomp271828 is offline Member
    Join Date
    Aug 2011
    Posts
    17
    Rep Power
    0

    Default

    Thank you Tolls. I will definitely check that out once I boot back into Linux. Right now I am in Windows and I may have some more details to help me fix the problem. I have 2 classes (NeuralNetwork and Driver). The Driver class contains main() and instantiates the NeuralNetwork class. In the debugger I told it to look for a ClassNotFoundException. It returned back this information about where the error occurred:

    line 12 of Driver:
    Java Code:
    NeuralNetwork myNet = new NeuralNetwork("C:\\Users\\Owner\\Documents\\school\\BU\\big data\\independent study\\class24_set1.txt");
    which was called from line 52 of NeuralNetwork:
    Java Code:
    fstream = new FileInputStream(location);
    This line is in a method that was called from the NeuralNetwork class constructor.

    It is telling me things like:
    Source not found: rt.jar has no source attachment.
    Source not found: URLClassLoader.class has no source attachment. etc ...

    Currently, the source attachment is pointing to C:/Program Files (x86)/Java/jre6/lib/rt.jar. Do I need to change this?
    Last edited by kthomp271828; 08-03-2011 at 11:49 PM.

  11. #11
    kthomp271828 is offline Member
    Join Date
    Aug 2011
    Posts
    17
    Rep Power
    0

    Default

    Actually, I will just throw up the entire code to see if anyone can figure the problem. There are no syntax errors but when I run it, it does nothing (but also doesn't terminate). When I run the debug it says there is a ClassNotFoundException. I just want to solve that problem so I can get to the actual code debugging.

    Java Code:
    package NeuralNet;
    
    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");
    		}
    	}
    }
    Java Code:
    package NeuralNet;
    
    import java.io.BufferedReader;
    import java.io.DataInputStream;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.StringTokenizer;
    
    /*neural network with one hidden layer*/
    public class NeuralNetwork {
    	private static int NUM_INPUTS;
    	private double[][] input;
    	private static int NUM_EXAMPLES;
    	private double[][] weight1;
    	private double[][] weight2;
    	private double[][] partial1;
    	private double[][] partial2;
    	private static int NUM_HIDDEN_NODES;
    	private double[][] hidden;
    	private static int NUM_OUTPUTS;
    	private double[][] output;
    	private double[][] classType;
    	private double[][] adjFactor1;
    	private double[][] adjFactor2;
    	private static double LEARN_FACTOR;
    	private double[][] errors;
    	
    	/*constructor*/
    	public NeuralNetwork(String location) throws IOException {
    		LEARN_FACTOR = 0.3;
    		NUM_INPUTS = 5; //number of variables
    		NUM_HIDDEN_NODES = NUM_INPUTS+1;
    		NUM_OUTPUTS = 2;
    		getNumExamples(location);
    		input = new double[NUM_EXAMPLES][NUM_INPUTS+1];
    		classType = new double[NUM_EXAMPLES][NUM_OUTPUTS];
    		hidden = new double[NUM_EXAMPLES][NUM_HIDDEN_NODES+1];
    		output = new double[NUM_EXAMPLES][NUM_OUTPUTS];
    		errors = new double[NUM_EXAMPLES][NUM_OUTPUTS];
    		adjFactor1 = new double [NUM_EXAMPLES][NUM_OUTPUTS];
    		adjFactor2 = new double [NUM_EXAMPLES][NUM_HIDDEN_NODES];
    		weight1 = new double[NUM_HIDDEN_NODES][NUM_INPUTS+1];
    		weight2 = new double[NUM_OUTPUTS][NUM_HIDDEN_NODES+1];
    		partial1 = new double[NUM_HIDDEN_NODES][NUM_INPUTS+1];
    		partial2 = new double[NUM_OUTPUTS][NUM_HIDDEN_NODES+1];
    		getData(location);
    		initialize();
    	}
    	
    	/*read file to determine the number of inputs*/
    	public void getNumExamples(String location) throws IOException {
    		FileInputStream fstream;
    		fstream = new FileInputStream(location);
    		DataInputStream in = new DataInputStream(fstream);
    		BufferedReader br = new BufferedReader(new InputStreamReader(in));
    		int count = 0;
    		while(br.readLine() != null)
    			count++;
    		NUM_EXAMPLES = count;
    		in.close();
    	}
    	
    	/*read inputs into array and pre-processes the data*/
    	public void getData(String location) throws IOException {
    		FileInputStream fstream;
    		fstream = new FileInputStream(location);
    		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++;
    			input[i][j] = 1;	//bias effect
    			StringTokenizer st = new StringTokenizer(line, ",");
    			while(st.hasMoreTokens()) {
    				j++;
    				switch(j) {
    				case 1:
    				case 2:
    					input[i][j] = preProcess(Double.parseDouble(st.nextToken()));
    					break;
    				case 4:
    				case 5:
    					input[i][j-1] = preProcess(Double.parseDouble(st.nextToken()));
    					break;
    				case 14:
    					input[i][5] = preProcess(Double.parseDouble(st.nextToken()));
    					break;
    				case 35: {
    					if(Double.parseDouble(st.nextToken()) == 2.0) {
    						classType[i][0] = 0.9; //class 2
    						classType[i][1] = 0.1;
    					}
    					else {
    						classType[i][0] = 0.1; //class 4
    						classType[i][1] = 0.9;
    					}
    					break;
    				}
    				}
    			}
    		}
    		in.close();		
    	}
    	
    	public double preProcess(double value) {
    		double newValue;
    		newValue = 0.8*(value/3)+0.1; //scales between 0.1 and 0.9
    		return newValue;
    	}
    	
    	/*zero out partial accumulators and randomize weights*/
    	public void initialize() {
    		int i,j,k;
    		for(i=0; i <= NUM_INPUTS; i++)
    			for(k=0; k <= NUM_HIDDEN_NODES; k++)
    				partial1[k][i] = 0;
    		for(k=0; k <= NUM_HIDDEN_NODES; k++)
    			for(j=0; j <= NUM_OUTPUTS; j++)
    				partial2[j][k] = 0;
    		for(i=0; i <= NUM_INPUTS; i++)
    			for(k=0; k <= NUM_HIDDEN_NODES; k++)
    				weight1[k][i] = Math.random();
    		for(k=0; k <= NUM_HIDDEN_NODES; k++)
    			for(j=0; j <= NUM_OUTPUTS; j++)
    				weight2[j][k] = Math.random();
    	}
    	
    	/*train the network using back propagation*/
    	public void trainEpoch() {
    		int r, i, j, k;
    		double sum;
    		for(r = 0; r < NUM_EXAMPLES; r++) {
    			hidden[r][0] = 1;
    			for(k = 0; k <= NUM_HIDDEN_NODES; k++) { //input layer to hidden layer
    				sum = 0;
    				for(i = 0; i < NUM_INPUTS; i++)
    					sum = sum + weight1[k][i]*input[r][i];
    				hidden[r][k] = 1 / (1 + Math.exp(-1*sum));
    			}
    			sum = 0;								//hidden layer to output layer
    			for(j = 0; j < NUM_OUTPUTS; j++) {
    				for(k = 0; k <= NUM_HIDDEN_NODES; k++)
    					sum = sum + weight2[j][k]*hidden[r][k];
    				output[r][j] = 1 / (1 + Math.exp(-1*sum));
    			}
    			for(j = 0; j < NUM_OUTPUTS; j++) {		//back propagate
    				errors[r][j] = output[r][j]-classType[r][j];
    				adjFactor1[r][j] = errors[r][j]*output[r][j]*(1-output[r][j]);
    				for(k = 0; k <= NUM_HIDDEN_NODES; k++)
    					partial2[j][k] = partial2[j][k]+adjFactor1[r][j]*hidden[r][k];
    			}
    			for(k = 0; k <= NUM_HIDDEN_NODES; k++) {
    				sum = 0;
    				for(j = 0; j < NUM_OUTPUTS; j++)
    					sum = sum + weight2[j][k]*adjFactor1[r][j];
    				adjFactor2[r][k] = sum*hidden[r][k]*(1-hidden[r][k]);
    				for(i = 0; i <= NUM_INPUTS; i++)
    					partial1[k][i] = partial1[k][i]+adjFactor2[r][k]*input[r][i];
    			}
    		}
    		adjustWeights();	
    	}
    	
    	/*adjust weights after an epoch of training*/
    	public void adjustWeights() {
    		int i,j,k;
    		for(k = 0; k <= NUM_HIDDEN_NODES; k++)
    			for(i = 0; i <= NUM_INPUTS; i++)
    				weight1[k][i] = weight1[k][i]-LEARN_FACTOR*partial1[k][i];
    		for(j = 0; j < NUM_OUTPUTS; j++)
    			for(k = 0; k <= NUM_HIDDEN_NODES; k++)
    				weight1[j][k] = weight1[j][k]-LEARN_FACTOR*partial2[j][k];
    	}
    	
    	public double getTotalError() {
    		double sum = 0;
    		for(int r = 0; r < NUM_EXAMPLES; r++)
    			for(int j = 0; j < NUM_OUTPUTS; j++)
    				sum = sum + errors[r][j];
    		return 0.5*sum;
    	}
    	
    	public int getNumExamples() {
    		return NUM_EXAMPLES;
    	}
    	
    	public int getNumOutputs() {
    		return NUM_OUTPUTS;
    	}
    	
    	public int getNumInputs() {
    		return NUM_INPUTS;
    	}
    	
    	public int getNumHidden() {
    		return NUM_HIDDEN_NODES;
    	}
    	
    	public double getWeight1(int k, int i) {
    		return weight1[k][i];
    	}
    	
    	public double getWeight2(int k, int i) {
    		return weight2[k][i];
    	}
    }

  12. #12
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,435
    Rep Power
    25

    Default

    when I run it, it does nothing
    Make it do something by adding lots of printlns to show where the execution is going and how the variables' values are changing.
    Can it be in an infinite loop?

  13. #13
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,435
    Rep Power
    25

    Default

    Not possible to run it without the input files.

  14. #14
    kthomp271828 is offline Member
    Join Date
    Aug 2011
    Posts
    17
    Rep Power
    0

    Default

    Excellent suggestion ... I added some println statements and iIt does seem to be an infinite loop. This boggles me since it's looping until it reaches the end of the input file and there are no more tokens. Since there aren't an infinite number of tokens, I don't understand why it's looping infinitely.

    Java Code:
    while(st.hasMoreTokens()) {
    				j++;
    				switch(j) {
    				case 1:
    				case 2:
    					input[i][j] = preProcess(Double.parseDouble(st.nextToken()));
    					break;
    				case 4:
    				case 5:
    					input[i][j-1] = preProcess(Double.parseDouble(st.nextToken()));
    					break;
    				case 14:
    					input[i][5] = preProcess(Double.parseDouble(st.nextToken()));
    					break;
    				case 35: {
    					if(Double.parseDouble(st.nextToken()) == 2.0) {
    						classType[i][0] = 0.9; //class 2
    						classType[i][1] = 0.1;
    					}
    					else {
    						classType[i][0] = 0.1; //class 4
    						classType[i][1] = 0.9;
    					}
    					break;
    				}
    				}
    			}

  15. #15
    kthomp271828 is offline Member
    Join Date
    Aug 2011
    Posts
    17
    Rep Power
    0

    Default

    Ok, I just fixed it by changing it to a "for" loop since I know how many tokens are in each line of input anyway. I guess it wasn't a ClassNotFoundException after all. I'm not sure why that error popped up in the debugger. Thanks everyone!

Similar Threads

  1. ClassnotFoundException
    By balaji shan in forum Java Servlet
    Replies: 8
    Last Post: 01-19-2011, 03:47 PM
  2. ClassNotFoundException
    By lgpublic in forum Advanced Java
    Replies: 5
    Last Post: 04-23-2010, 03:05 PM
  3. ClassNotFoundException
    By Edward in forum New To Java
    Replies: 2
    Last Post: 06-29-2009, 07:08 PM
  4. ClassNotFoundException JSP
    By TDMaster in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-27-2009, 07:41 AM
  5. ClassNotFoundException
    By Chezelle in forum Java Applets
    Replies: 5
    Last Post: 12-24-2008, 04:26 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
  •