Search code examples
javajarjavac

how to avoid using javac -cp


I have a Java class which uses a .jar file.

Every time that I want to compile this class, I have to do something like javac -cp ".:myJar.jar" myClass.java and every time that I want to execute it, I have to do the similar thing but with java instead of javac.

Is there a way to avoid doing this?

I know that I could put this jar file into my class path but I don't want to do that. I don't neither want to do a maven projet.


Solution

  • There is nothing preventing you from using an IDE, taking advantage of all its super useful features when developing the program, and then submit just the source code and associated jars to the professor.

    Advantages of using IDE that your professor don't need:

    • Syntax color-coded editors with auto-complete.

    • Built-in display of javadoc, so you know what all the built-in Java methods do, and how they work.

    • Instant high-lighting of syntax errors.

    • Never having to compile the code, since IDE always keeps the code compiled.

    • Easy single-button execution of the program when you want to run it.

    • Debugger. Very important feature when your code is not working as you intended.

    • ... more ...