Search code examples
javabashjavac

How do I compile using javac in command line this small code snippet


I am learning springframework and I don't want to use any IDE, and I want to work in java in pure command line in bash. I already have downloaded lots of jar I can see them in /root/.m2/repository as well as in /usr/share/maven/ref/repository/ too. The AppConfig.java i want to compile has the below content:

@Configuration
public class AppConfig {
    // this is all there is
}

It compiles fine without the @Configuration annotation. At the top of my head, I know that I need to pull-in the correct jar. To be systematic in future dealings of these things, I want to know how to:

  • Identify the correct jar and location of jar needed for a keyword

I accept maven pom.xml way of doing things if needed, but if possible I want to work in the most minimal way.


Solution

  • The real non answer: don't do that.

    For a complete newbie just starting with Java it can be beneficial to first do all work himself - using only a text editor and javac manually. Because that teaches you a lot of things.

    But: the spring framework is nothing that Java newbies should start with. And when you are more experienced, you stop doing all things manually. Then you rather focus on using all the tools that are around to make your life easier. Thus: when working with spring - use an IDE and a build system such as maven or grade. Because sprint itself adds (several) ordes of magnitude of complexity.

    Like in: when you start as an architect, you might use a shovel yourself to dig the basement for your garden house. But as soon as you intend to do "real work", you forget about the shovel and start using excavators.