Hi everybody
Help me please to figure out what's wrong with my code
When I try to compile it it gives me an error ClassNotFoundException
I have never had such an error befoure, so I don't know what to do....

import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

public class Example {
	
	public static String colors[] = {"blue", "black", "white"};
	
	public Example() {
		List<String> colorList = new LinkedList<String>();
		for(String color : colors)
			colorList.add(color);
	
		convert(colorList);
		printList(colorList);
	}
	public static void main (String args[]) {
		new Example();
	}
				
	public static void convert(List<String> list) {
		ListIterator<String> iterator = list.listIterator();
		
		while(iterator.hasNext()) {
			String nextString = iterator.next();
			iterator.set( nextString.toUpperCase());
		}
	}
	public static void printList(List<String> list) {
		System.out.println("List : ");
		for(String color : list)
			System.out.printf("%s ", color);
	}
}
Exception in thread "main" java.lang.NoClassDefFoundError: 
Caused by: java.lang.ClassNotFoundException: 
	at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: . Program will exit.

I compiled this as-is and it compiled and ran with no problem.
Maybe your path and/or CLASSPATH are not properly set up.

C:\science\java\DaniWeb\413619>javac Example.java

C:\science\java\DaniWeb\413619>java Example
List :
BLUE BLACK WHITE
commented: Thanks a lot, that's right +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.