Packages - A set of rules to keep your compiler and interpreter happy happy.

Many people in comp.lang.java.programmer have problems compiling when they first enter the dizzy world of packages. There are various ways you can get everything to work, and this is just one of them - but I believe it's one of the easiest ways to get things to work.

Setting the scene

Coding and compiling

Running the application

Many people "accidentally" end up with their classes in the right place, etc, just by luck, but then run into errors like: java.lang.NoClassDefFoundError: MyCompanyApp (wrong name: com/mycompanypackage/MyCompanyApp. Hopefully, if you've understood everything above, you won't run into this. It happens if you try to run your code using something like this:
c:\java\com\mycompanypackage> java MyCompanyApp
Here's how to avoid it:

Back to the main page.