3

so I coded a little thing to try and I don't know why eclipse isn't running my code. Please help I'm new to coding. Error occurred during

import java.util.GregorianCalendar;
import java.util.Scanner;

public class Calendar {

    public static void main(String []args) {

        GregorianCalendar cal1 = new GregorianCalendar();
        Scanner input = new Scanner(System.in);
        System.out.println("Please enter your hire year (yyyy):  ");
        int hireYear = input.nextInt();
        int currYear = cal1.get(GregorianCalendar.YEAR);
        System.out.println("He's worked here for " + (currYear - hireYear) + "years!");     
    }
}

initialization of boot layer java.lang.LayerInstantiationException: Package jdk.internal.jimage.decompressor in both module java.base and module jrt.fs

Konstantin
  • 133
  • 1
  • 8
Jonny Murillo
  • 81
  • 1
  • 4
  • Possible duplicate of [RuntimeException: Package jdk.internal.jimage.decompressor in module jrt.fs and module java.base](https://stackoverflow.com/questions/42986287/runtimeexception-package-jdk-internal-jimage-decompressor-in-module-jrt-fs-and) – KevinO Apr 24 '18 at 22:41
  • Also, if you installed Java 9, unless there is a pressing reason for it, I'd use Java 8 at the moment. – KevinO Apr 24 '18 at 22:42
  • I use jdk 10 at the moment – Jonny Murillo Apr 24 '18 at 23:22
  • 1
    Well, OK 9 or 10. Try downgrading to Java 8. Also, IIRC, support for Java 10 must be added to Eclipse. – KevinO Apr 24 '18 at 23:23

3 Answers3

0

this seems to happen when there's multiple versions of java (previous to 9 and 9+) see this bug report for eclipse maybe try using another IDE or use command line for compiling and running

user1
  • 254
  • 1
  • 15
0

Are you using Eclipse Photon? This isn't officially released yet (but I've found it quite stable). It does look like Bug 532490, which is a very recent regression and it will be fixed in the next ~ 6-weekly milestone update.

In the meantime, right-click your project > Build Path > Configure Build Path > 'Libraries' tab. Double-click "JRE System Library" and change it from 8 to 10. Build & run and the problem should be gone.

As a rule it is good to compile and run using the same JRE/JDK. It is possible to mix and match these, but I would say it should only be done in certain "advanced usage" scenarios.

Luke Usherwood
  • 3,082
  • 1
  • 28
  • 35
0

The only thing that worked for me when I had this error was uninstalling then reinstalling Eclipse. Then I made sure to make all future java projects with java version 1.8 (when creating a java project, under JRE, select "use an executing environment JRE:", then select "JavaSE-1.8"). Hope that helps!

Beatrice
  • 76
  • 9