views:

297

answers:

1

I am writing a curriculum project for students new to Java. It has a folder structure as so.

myjar.jar
solutions/my/really/long/package/MySolution.class

I got it so the jar can load all classes in the solutions/my/really/long/package/ directory. by adding 'solutions/' to the classpath.

My question is if it is possible to set it up so there is no long nested folders for the package without using the default package.

The resulting structure would be

myjar.jar
solutions/MySolution.class

But the MySolution class would not have a default package.

+4  A: 

Well, you could write your own classloader. That would probably do the trick - but it's really not a nice thing to do, and in particular your students would then get used to something which wouldn't work in the real world.

Why not just use a short package name?

Jon Skeet
Or custom URLStreamHandler (like the jar protocol). But, yes, why?
Tom Hawtin - tackline