Jump to content
  • Advertisement
Sign in to follow this  
hisDudeness

applet packaging

This topic is 4862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I guess I don't really understand the usefulness of the Java package, let alone the syntactical implementation. As far as I understand, you declare a Java program (applet or otherwise) to belong to a specific package to sort of give it its own namespace. If that's all the package is for, then I guess I get it. But my guess is that I'm only seeing the tip of the iceberg. 1. Write now I have my JApplet class, Widget, saved in a directory called MyApplet on the desktop. If I were to throw the statement: package Widget; in at the top of Widget.java, would this change where the .class file would be compiled to? In fact, would it change any of the file/directory setup I have right now? Could I call the package 'widget' (not uppercased) and get away with it, or does the package have to equal the class name? 2. What if my widget package from above has three packages which store underneath it: a, b and c. And what if package 'a' itself has three packages that store underneath it: x, y and z. If I write the following code: import widget.*; Does this statement import just a, b and c into the program, or does it import all the child packages of 'a' (x, y and z) as well?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
would this change where the .class file would be compiled to? In fact, would it change any of the file/directory setup I have right now? Could I call the package 'widget' (not uppercased) and get away with it, or does the package have to equal the class name?


No, no, and heck no.

Quote:
What if my widget package from above has three packages which store underneath it: a, b and c. And what if package 'a' itself has three packages that store underneath it: x, y and z. If I write the following code:

import widget.*;

Does this statement import just a, b and c into the program, or does it import all the child packages of 'a' (x, y and z) as well?


If you tried to use the shorthand name for classes in any of your packages except widget, you will get a compiler error because it won't be able to resolve the type. That means that you can't use classes or interfaces in package a, b, c, x, y, or z.

If you want to use classes in package a, you must type:

import widget.a.*;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!