Archived

This topic is now archived and is closed to further replies.

ARCHIGAMER

[java] intermediate question (I think)

Recommended Posts

ARCHIGAMER    122
When I create a package for a java does it have to be compiled and distrubuted with the program or u just usethe import statement and thats the end of it. I wish there was a button on my monitor to turn up the intellegince. Theres a button called 'brightness' but it doesn't work

Share this post


Link to post
Share on other sites
joeG    172
Think about this: if you didn''t distribute your package with your app and called import com.your_package.* then where would the Java interpreter find your pacage? It''s no where on the client''s machine, and as far as I know the only way to have an app on one machine and the package on another is if you are writing an applet.

So, I would assume that you have to distribute your packages along with your app. Bummer considering how easy it is for people to decode those .class files.

Oh well.



joeG

Share this post


Link to post
Share on other sites
joeG    172
But you can write a little bit of code to implement a customized class loader that would load classes from a network connection, or some other encrypted source, or...whatever situation you''re in.

I''ve never messed with subclassing java.ClassLoader but I''m sure there''s a bunch of tutorials out there that could help you out.

It doesn''t seem like an optimal solution though, so you may just be stuck with sending the packages with your application



joeG

Share this post


Link to post
Share on other sites
bobbin    122
Packages serve to group together a collection or _related_ classes. If you don''t define a package name then all classes in that file belong to a default unnamed package, so you can''t really get away with having no packages.
The import statement is just there to save time including all the classes from a package (i.e. i can say import java.io.* so i don''t have to define like: java.io.File file i can say File file).
You don''t need the package directive, but when running your code you need to just call the class name (normally java packageName.className)

Why are some developers so concerned with mashing up their byte code? Do you really care if someone can open up your class, infact this is ment to be this way so that reflection classes can get method/structure information on run-time class instances! Hay I can open .exe/.com filez with debug + i know asm, does this mean that its unsafe?? NO course it don''t! You can make any code in any language unsecured by doing stupid things (like hard coding keys etc.)....

Share this post


Link to post
Share on other sites
ARCHIGAMER    122
i was just wondering if it had to be included or not. I am not afraid

I wish there was a button on my monitor to turn up the intellegince.
Theres a button called 'brightness' but it doesn't work

Share this post


Link to post
Share on other sites