Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8153556

javac: "cannot access unnamed package" message when use jar file where entres with '/' in front of classname

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • 10
    • 9
    • tools
    • None
    • 9

      When compiling code against a jar files contains classes in unnamed package, the following error message is produced:

      $ javac -cp getuid.jar Test.java
      Test.java:1: error: cannot access unnamed package
      public class Test {
      ^
        /getuid.class
      1 error

      The cause is that the jar file has /getuid.class entry instead of getuid.class. However, the same jar file works for JDK 8.

      javap also reports class not found with the problematic jar, where javap in JDK 8 works.

        1. Test.java
          0.0 kB
        2. getuid.jar
          0.5 kB

            Unassigned Unassigned
            henryjen Henry Jen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: