Prohibited package name: java

后端 未结 6 1243
灰色年华
灰色年华 2020-11-27 22:21

I tried to get the data from my database name as jaane with user name Hello and Password hello. Error:

java.lang.SecurityException: Prohibited package name:          


        
相关标签:
6条回答
  • 2020-11-27 22:39

    You need to specify the Database Name, and there are two slashes before localhost. I assume hello is your username and Hello the password...

    Connection connection = DriverManager.getConnection( "jdbc:derby://localhost:1527/DatabaseName","hello","Hello" );
    

    ...that is after you change your package name to something other than java!

    0 讨论(0)
  • 2020-11-27 22:42

    If your project is inited by Gradle, I recommend you to change the project by specifying the package name, then we can avoid the problem.

    gradle init --type java-application --test-framework junit --package packname
    
    0 讨论(0)
  • 2020-11-27 22:46
    java.lang.SecurityException: Prohibited package name: java
    

    You cannot use java as the name of your package. Replace it to something else.

    0 讨论(0)
  • 2020-11-27 22:57

    Change your package name. java as a package name is prohibited.

    Edit: Move your Main.java file in a (source) directory that doesn't start with java or javax and use the directory structure names to change your package name in the code.

    0 讨论(0)
  • 2020-11-27 23:00

    Never Keep your class in a root package as "java" or never create a package starting as java. ... you can use any other identifier as your package name.

    0 讨论(0)
  • 2020-11-27 23:01

    Look at why `java.lang.SecurityException: Prohibited package name: java` is required?

    User code is never allowed to put classes into one of the standard Java packages. That way, user code cannot access any package-private classes/methods/fields in the Java implementation. Some of those package-private objects allow access to JVM internals. (I'm thinking of SharedSecrets in particular.)

    0 讨论(0)
提交回复
热议问题