Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7168509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:47:42+00:00 2026-05-28T14:47:42+00:00

everyone. I used openjdk-7 on arch linux. I started to learn Java recently, and

  • 0

everyone.

I used openjdk-7 on arch linux. I started to learn Java recently, and encountered such a problem:

I created a file at /home/hqwrong/Code/java/mew/Mouth.java:

package mew;

public class Mouth{
   public static void main(String argv[]){
       pickle.Say s = new pickle.Say();
  }
}

and another one at /home/hqwrong/Code/java/pickle/Say.java :

package pickle;

public class Say{
   public Say(){
      System.out.println("Say");
   }
}

I compiled Say.java to Say.class,using:

$ cd /home/hqwrong/Code/java/pickle
$ javac Say.java

which is successful.

I compiled Mouth.java ,using:

$ cd ../mew
$ export CLASSPATH=.:/home/hqwrong/Code/java/
$ javac Say.java

no error message.

But after I type:

$ java Say

I got:

Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.mew
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:649)
at java.lang.ClassLoader.defineClass(ClassLoader.java:785)
 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:472)

It’s same when I use:

$ java -cp $CLASSPATH Say

I need your help,please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:47:43+00:00Added an answer on May 28, 2026 at 2:47 pm

    Since there is no good answer yet, I’ll post mine.

    First, you should really have a separate folder for your classes and your sources. I suggest using java/src for your sources, and java/classes for your classes. Since the classes are stored in the classes folder, this is the one that should be in the classpath.

    The folder tree of your sources should then match your package tree. This means that the class mew.Mouth must contain the line package mew, be defined in the Mouth.java file, in the java/src/mew folder.

    To compile your classes, put you in the java/src directory, and use the following command:

    javac -d ../classes mew/Mouth.java pickle/Say.java
    

    The compiler will automatically generate the folder structure matching the package structure in the classes directory. If you make structural modifications in your source tree, just remove everything in the classes folder, and recompile everything.

    To run your classes, you must refer to their fully qualified name. And the folder containing your package tree (the java/classes folder) must be in the classpath. Once this is done, from everywhere, you can use

    java mew.Mouth
    

    Note that, as you have discovered, the java and javax packages are reserved. You can’t use them for your own classes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has everyone ever programatically created a custom attribute? (At the moment I've just used
everyone, I met a problem about APNs when I used the code below. I
everyone I wrote simple music player, but I have one problem. I used ajax
Everyone managing open-source-software runs into the problem, that with the time the process of
I used to think that everyone used relative paths (e.g. /styles/style.css ). But I
everyone. I used Ruby and Rails before, and I enjoy Rails's ORM, which make
Has everyone migrated to MPI (message passing interface) or is PVM still widely used
Alright everyone, Let's say i wanted to make a system that used only assembly
I'm trying to port the old HTML.Image helper, that I'm sure everyone has used
Created a AlertDialog that is used to prompting the user to enter a keyword.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.