1

Hi can anyone help me with this?

public class XCopy {
   public static void main(String[] args) {
      int org = 42;
      XCopy x = new XCopy();
      int y = x.jazda(org);
      System.out.println(org + " " + y);
   }
   int jazda(int arg) {
      arg = arg*2;
      return arg;
   }
}

Compiler doesn't see any problems, but results shows this:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
        at XCopy.main(XCopy.java:5)
SomeJavaGuy
  • 7,307
  • 2
  • 21
  • 33
Ernesto
  • 950
  • 1
  • 14
  • 31
  • 1
    There shouldn´t be any problem with your code. How are you executing it and how are you compiling it(with javac, IDE) ? – SomeJavaGuy Dec 17 '15 at 08:18
  • What code is in line 5? Could you somehow show a bit more code and error message please? – Aron_dc Dec 17 '15 at 08:19
  • Error message is: Exception in thread "main" java.lang.Error: Unresolved compilation problem: at XCopy.main(XCopy.java:5) Line 5: public static void main(String[] args) { I use Eclipse – Ernesto Dec 17 '15 at 08:22
  • are you sure your JDK/JRE are set up properly in Eclipse and in your environment variables? There is no reason for this not to work. – EpicPandaForce Dec 17 '15 at 08:25
  • 1
    Did you copy your code from some other source via CTRL+C,CTRL+V? Sometimes the encoding leads to compiling errors. – Aron_dc Dec 17 '15 at 08:33
  • Try writing the same code FROM SCRATCH in an empty new file (not by copy and paste). Observe the behaviour. – Honza Zidek Dec 17 '15 at 09:10

1 Answers1

-1

Check whether the Eclipse option "Project" - "Build automatically" is enabled.

Markus Lausberg
  • 12,177
  • 6
  • 40
  • 66