Jump to content
  • Advertisement
Sign in to follow this  
Nanook

cant run .. (classpath?) [java]

This topic is 3729 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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)
			       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, inputArray);
			if (count == 0)
				Screen.out.println("There is no " + vowelArray + "'s appearing");
			else
			{
				index = searchChar(vowelArray, inputArray);
				Screen.out.println("There is " + count + " " + vowelArray + "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
Advertisement
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
Got it working: :)

F:\ict102\week8>java -classpath .;D:/progs/Java/jdk1.5.0_08/jre/lib/ext/B102.jar
vowel

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!