2

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.

2
  • What's wrong with the class files in their appropriate package directory structure? Commented Dec 16, 2008 at 21:19
  • It works, just can be a hassle, especially for a new programmer. Commented Dec 16, 2008 at 21:42

1 Answer 1

4

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?

Sign up to request clarification or add additional context in comments.

1 Comment

Or custom URLStreamHandler (like the jar protocol). But, yes, why?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.