Java: How to compile and run in Windows command-line

Let's say we want to test GSON library in Windows command-line. Here is what to do step-by-step
  1. Install Git for Windows and "xargs"
  2. cd c:\temp
  3. git clone
  4. cd c:\temp\gson\gson\src\main
  5. mkdir ..\build
  6. dir /b /s *.java | xargs javac -d ..\build
  7. cd ..\
  8. jar cf ..\gson.jar -C build .
Now gson.jar is created.

Next, create a Java source file with the following contents:


public class SimpleTest {

    static class TestObj {
        int value1 = 1;
        String value2 = "abc";

    public static void main(String[] args) {
        Gson gson = new Gson();

        TestObj[] objs = new TestObj[3];
        for (int i = 0; i < objs.length; ++i)
            objs[i] = new TestObj();

        List objs2 = new ArrayList();

Save it to c:\temp\

Then compile it:

And run it If it is to be run in Linux, replace ; (before gson.jar) by :