Sign in to follow this  
Nanook

cant run .. (classpath?) [java]

Recommended Posts

I get to compile my program but I cant run it.. This is the error msg:
F:\ict102\week8>java vowel
Exception in thread "main" java.lang.NoClassDefFoundError: B102/Screen
        at vowel.readN(vowel.java:61)
        at vowel.main(vowel.java:74)
Caused by: java.lang.ClassNotFoundException: B102.Screen
        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)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        ... 2 more

F:\ict102\week8>


CLASSPATH in environment variables is set to: D:\progs\Java\jdk1.5.0_08\jre\lib\ext\B102.jar; and this is my code:
import B102.*;

class vowel
{
	public static int searchChar(char c, char inputArray[])
	{
		int i;
		for(i = 0;i < inputArray.length; i++)
			break;
		return(i);
	}

	public static int countChar(char c, char inputArray[])
	{
		int count = 0;
		for(int i = 0; i < inputArray.length; i++)
			if (c == inputArray[i])
			       count++;
		return(count);	
	}
	
	public static void print(char inputArray[], char vowelArray[])
	{
		int count, index;
		for(int i = 0; i < vowelArray.length; i++)
		{
			count = countChar(vowelArray[i], inputArray);
			if (count == 0)
				Screen.out.println("There is no " + vowelArray[i] + "'s appearing");
			else
			{
				index = searchChar(vowelArray[i], inputArray);
				Screen.out.println("There is " + count + " " + vowelArray[i] + "s appearing, and the first one is on index " + index);
			}
		}
		return;	
	}
	
	public static void getInput(char inputArray[], char vowelArray[])
	{
		char c;
		for(int i = 0; i < inputArray.length; i++)
		{
			Screen.out.println("Enter a vowel (a,e,i,o,u) (" + inputArray.length + " max, # to quit:");
			c = Keybd.in.readChar();
			for(int j = 0; j < vowelArray.length; j++)
			{
				if (c == vowelArray[j])
				       inputArray[j] = c; //is this needed? it does not matter if I save a none vowel char for the rest of the code anyway?
			}
			if (c == '#')
				break;
		}
	}

	public static int readN()
	{
		int n;
		do
		{
			Screen.out.println("How many vowels do you want to read in?");
			n = Keybd.in.readChar();
			if (n <= 0)
				Screen.out.println("Wrong input");
		}while(n <= 0);
		return(n);
	}


	public static void main(String args[])
	{
		char vowelArray[] = {'a','e','i','o','u'};
		int n;
		n = readN();
		char inputArray[] = new char[n];
		getInput(inputArray, vowelArray);
		print(inputArray, vowelArray);
	}
}



I got the B102 file from uni

Share this post


Link to post
Share on other sites
I managed to get rid of some of the errors.. I realized I had alot of old java versions lying around so I unistalled everything that had to do about java and reinstalled the most resert version.. but I still get this error:


F:\ict102\week8>java vowel
Exception in thread "main" java.lang.NoClassDefFoundError: B102/Screen
at vowel.readN(vowel.java:61)
at vowel.main(vowel.java:74)

F:\ict102\week8>


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this