2

I really like the way we compile and produce the executable in a nice simple way using cargo in Rust. Just typing cargo run takes care of building and running the program. The best part is that it is included in the Rust distribution. But in Java, is there any such batteries-included feature that allows us to achieve the same. For example, if I have a root directory named app and two sub-directories called bin and src. Inside of src, I have the standard package structure like com/company/main/java and then directories containing the code. So in the root directory, when I execute the command javac, is there any flag or command or config file that I need to use so that I get a compiler jar in the bin directory or at least the compiled class files in the bin directory in the same structure as the code is placed in src ?

NOTE : I am not looking for a build system like Maven, Gradle, etc. I am specifically looking forward to do this using just two commands that come with the JDK, javac and java.

1 Answer 1

0

Your question can be positively answered now. Starting from Java JDK 22 due to JEP 458 you can just use java Main.java command and it will use directories as packages containing the rest of the code.

Not the answer you're looking for? Browse other questions tagged or ask your own question.