Reputation:
I want someone to be able to compile the code without then having to set the CLASSPATH to the project directory. Is this possible?
Upvotes: 0
Views: 215
Reputation: 128879
Use a build tool, like Ant or Maven. They use a project descriptor of one sort or another to manage the classpath for you.
Upvotes: 1
Reputation: 346347
The classpath needs to be set somehow, though using the environment variable is not recommended these days. Typically, projects that people are supposed to compile for themselves are distributed with either an Apache Ant build script or a Maven POM descriptor. Both of these build automation systems can do much more than just compilation, but both require some time to learn if you haven't used them before. However, it is time well spent, as they can save you a lot of time on all kinds of repetitive tasks, and both are very commonly used in Java projects.
Upvotes: 2
Reputation: 14786
Sounds like you want to create a .jar
The jar tool in the JDK puts your .class files in an archive. Then you can just reference the archive on the classpath or with the -jar flag for the java executable.
If you create a manifest for the jar, you can make the .jar runnable with a click from Windows and most other desktop environments.
Upvotes: 0