Package is not visible error

前端 未结 2 618
無奈伤痛
無奈伤痛 2021-02-14 11:54

I was trying to use joptsimple package in my project but I get following error:

Error:(4, 20) java: package jdk.internal.joptsimple is not visible
  (package jdk         


        
2条回答
  •  再見小時候
    2021-02-14 12:39

    You are apparently using an internal API, which you shouldn't. Such APIs are not standardized - they can differ from JVM to JVM and may change at any time without notice.

    That said, if you still want to use it, you can do so by adding the following command line flag at compile and run time (i.e. to javac and java):

    --add-exports jdk.internal.opt/jdk.internal.joptsimple=ALL-UNNAMED
    

    If you are creating a module you can replace ALL-UNNAMED by your module name.

提交回复
热议问题