0

What's the simplest way to compile java source files without an IDE?

I'm mainly using Java for algorithms, and these questions don't really need full fledged project environments. Although being able to import some reusable classes would be nice.

In Go, I'm able to structure my project like so:

$HOME/src/<dir>/<dir>

And compiling it ends up in $HOME/bin/* (apps) or $HOME/pkg/<dir>/<dir> (libraries).

Is there some way to do something like this, but for java?

user1164937
  • 1,979
  • 2
  • 21
  • 29
  • Use [tag:maven], [tag:ant], [tag:sbt] **or** [tag:gradle]. – Elliott Frisch Jun 19 '16 at 02:40
  • 1
    @ElliottFrisch You forgot `javac`. It's perfectly fine for something this simple. – Andreas Jun 19 '16 at 03:35
  • If I understood you right, you are looking for something like `javac project/*.java` – Yev Jun 19 '16 at 03:42
  • I strongly suggest you make the investment in learning how to use an IDE. You can get started and use it for basic compilation without having to invest in a "full fledged project environment". Going from command line to IDE requires some adjustment but the productivity difference on anything more complex than simple toy projects is like the difference between a Yugo and a Ferrari. Learn how to use the debugger and you can substitute a Boeing 787 for the Ferrari. – Jim Garrison Jun 19 '16 at 05:40

1 Answers1

0

The javac and jar commands will compile Java code and create jar files. Your source code has to be in a directory structure that matches the structure of the packages. This means that the directory java/awt would contain the java.awt package source files. Many years ago, I used a set of UNIX script files to compile and package my Java code, but this was before I had worked with Eclipse.

Bradley Ross
  • 445
  • 2
  • 8