0

I am practicing for USACO Bronze and came across the Fence Painting Problem from USACO 2015 December. My code is working on Eclipse and everything is fine but when the USACO website tests it, I get this error:
Error: Could not find or load main class Paint
Caused by: java.lang.NoClassDefFoundError: introduction/Paint (wrong name: Paint)

I have no idea what is causing this.
This is my code:

package introduction;

import java.io.*;
import java.util.*;
public class Paint {
    public static void main(String args[]) throws IOException {
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("paint.out")));
        
        Scanner keyboard = new Scanner(new FileReader("paint.in"));
        
        int a = keyboard.nextInt();
        int b = keyboard.nextInt();
        int c = keyboard.nextInt();
        int d = keyboard.nextInt();
        
        if (a<c && b==d) {
            out.println(b-a);
        }
        if (a<c && b<d) {
            out.println(d-a);
        }
        if (a<c && b>d) {
            out.println(b-a);
        }
        if (a>c && b==d) {
            out.println(d-c);
        }
        if (a>c && b<d) {
            out.println(d-c);
        }
        if (a>c && b>d) {
            out.println(b-c);
        }
        if (a==c && b==d) {
            out.println(b-a);
        }
        if (a==c && b<d) {
            out.println(d-c);
        }
        if (a==c && b>d) {
            out.println(b-a);
        }
        out.close();
    }
}
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
A S
  • 1
  • i think that's a reserved name https://docs.oracle.com/javase/8/docs/api/java/awt/Paint.html – Eduard A Feb 18 '21 at 21:57
  • Some clues at https://stackoverflow.com/a/7509317/2568649 – Chris Feb 18 '21 at 22:03
  • 1
    @avrm I think reserved names would relate to language terms (class, final, private etc). - there should be no conflict with a Paint class in the java.awt package (AFAIK) – Chris Feb 18 '21 at 22:05
  • 1
    yes indeed.. i don't know then.. – Eduard A Feb 18 '21 at 22:16
  • For this error, 99% of the time it means your deployment environment differs from your build environment. Either a jar is missing in deployment, or the jar in deployment is a different version from the one in build. – Jim Garrison Feb 19 '21 at 00:33
  • @avrm TBH I'm not sure exactly what the problem is either, just didn't want AS to get confused :-) – Chris Feb 19 '21 at 21:11
  • Does the USACO website require the class to have a specific name? – enzo Aug 18 '21 at 17:05

0 Answers0