Gradle, Ant and Maven all have a steep learning curve, especially if you are not familiar with any of them and not used to working in the Java ecosystem. I mean, it's easy to find 'Hello World' tutorials for those, and they are - of course - fully documented in manuals. But if you want to do something more than 'Hello World', something which "should" be simple, that's when they become hard (until you are expert, which takes time).
Most Java experts able to help you by answering this question have years of experience in Gradle, Ant, Maven and one of the IDEs - so expert that they have forgotten the early days pain.
The real purpose and power of Gradle or Ant is to carry out all build steps of a complex project, automatically. They are batch or script processors tailored to all the things you need to do when building large Java projects - Gradle is more specific to build steps, Ant is more general, but either one could be used. For example, I use Gradle for an open source project where I need to fetch the latest source code from two different Github projects, check the libraries are up-to-date, update the build number, and build two different binaries being a "production" version and a "development" version, and pack them into .jar files - and I create builds like this over and over, every time the code changes. It can take many hours of coding time just to get the gradle set up exactly right to automate this type of thing.
It's probably not worth using Gradle or Ant for building a simple project. As others have said, the command line compiler javac
is enough for a simple project.
The best advice I can give is "bite the bullet". Take the trouble to learn the basics properly. Install and use one of the IDEs (Eclipse or IntelliJ).
Then you will find creating new Java projects is quick and easy. The IDEs are suited for both small and large projects.
Golden tip: Install Maven and use it from day 1, make all your projects Maven projects. If copying other people's code from tutorials or open source projects, pay attention to the dependencies and their versions, and copy the dependencies into the Maven pom.xml
for your own project. Dependencies = libraries.
Since part of your question appears to be "is it worth me learning these tools for this language which I don't yet know" I will set out some general advantages and disadvantages of Java.
Advantages of Java:
- exact same code runs on Windows, Mac, or Linux (ok you might need to add native libraries for a few things like direct access to sound or graphics if you are coding games, but these libraries are readily available)
- excellent libraries
- excellent IDEs, will detect syntax errors and many common coding errors before you build
- strongly-typed language so that some common kinds of coding errors are simply impossible
- easy to understand code for humans (depends on coding skills)
- high performance is possible (depends on coding skills)
- fast execution, almost as fast as the compiled languages like C++ and Go (Java is compiled to bytecode, the bytecode is then interpreted on the runtime platform which has built-in optimisers)
- tidy installation of projects and their executable code, everything related to the project stays inside one folder path
- the IDE can hot-load your code edits into running code (so you can edit your code and immediately see the results in a running code window)
- can scale up to very large projects
- never any need to worry about garbage collection, it's automatic
- your completed app can be distributed as a single binary file (a .jar file)
- if you learn Java, you have gained a lot of Javascript knowledge as well (totally different language but the syntax is the same)
- Android apps are written in a super-set of Java
- not tied to one specific vendor (you are not tied in to Microsoft)
- if you don't like Java itself, there are other languages with different syntax which are essentially Java under the hood, examples are Scala and Groovy (in the same way that Visual Basic and C# are essentially the same language under the hood)
Disadvantages of Java
- creating a GUI in Java is hard work, all the tools are a bit sucky
- string processing in Java is good (plenty of library methods) but slow and memory-heavy in production code
- multi-threading is well supported, but uses a lot of memory in production code (each thread has its own stack) - this problem is partially solved by reusable ThreadPools
- there are plenty of Java libraries and platforms for web apps, but they all tend to be a bit bloated and heavy
- running a mid-sized or large app needs 10 seconds or even longer on initial load