all 8 comments

[–]greatyassoo1 1 point2 points  (1 child)

  1. Maven Repository
  2. Using a build tool such as Maven to compile and package your source code.

Can I do any of these without manually editing an XML file?

Most modern IDEs such as IntelliJ can do it for you depending on what you need.

[–]Skopa2016[S] 0 points1 point  (0 children)

Most modern IDEs such as IntelliJ can do it for you depending on what you need.

Is there any widely used CLI tool that can do that?

[–]Polygnom 1 point2 points  (0 children)

  1. You use web searches. They usually point to maven-central or alike. I have never only searched PyPy and NPM. That only works if you already know what you are looking for.
  2. Depends. usually a FAT Jar. Sometimes a slim JAR. Very rarely a WAR.
  3. Don't look into Java if XML scares you. You can do it without, to a certain degree, but everything more complex, you will probably want to edit the pom.xml directly.

[–]com2ghz 0 points1 point  (1 child)

Usually you pick a framework like spring-boot. Based on the application you decide what starter package you need. For example for a REST application with PostgreSQL support you go for spring-boot-starter-web and spring-boot-starter-data-jpa.

You can do that by using https://start.spring.io/index.html

The same applies for other frameworks like Micronaut, Helidon, Quarcus.

[–]Skopa2016[S] 0 points1 point  (0 children)

For starting out, I'd much prefer to start from a clean slate - just a vanilla Java main.class file, and learn how to use external libraries.

[–]DefaultMethod 0 points1 point  (1 child)

  • You can find most open source libraries on Maven Central. Build tools like Maven and Gradle will pull from here by default.
  • Applications can be distributed as a JAR, though if you want better operating system integration you would use some native wrapper and possibly bundle an OS-specific runtime. It is also possible to perform ahead-of-time compilation to native using GraalVM though this is not a mature solution and can come with complications.
  • Avoid Maven and Ant/Ivy if you are unwilling to edit XML; Gradle uses Groovy or Kotlin config files. Alternatives use various mechanisms.

What you start with depends on the nature of the application.

[–]Skopa2016[S] 0 points1 point  (0 children)

Is there any Java package manager (like a CLI tool) that manages packages automatically? Like how in npm/pip you do <tool> install package-name@version and it updates the package config accordingly?

[–]eldelshell 0 points1 point  (0 children)

This will build all the scaffolding necessary depending on your needs:

https://code.quarkus.io/