From charlesreid1

Revision as of 05:25, 19 March 2017 by Admin (talk | contribs)

Cool: http://www.ibm.com/developerworks/library/j-robots/index.html

Getting Started

Download and install Java, if you need to.

Hello World

This will walk through compiling and running a "Hello world" example in Java.

The program

Here's a simple Java "Hello world" program:

public class HelloWorld {
    public static void main(String[] args) { 
        System.out.println("Hello world!");
    }
}

Compiling

To compile this program, use the javac command:

$ javac HelloWorld.java

This will create a HelloWorld.class file, which is the Java executable.

Running

To run a Java executable, use the java command, and pass it the executable's filename without the extension:

$ java HelloWorld
Hello, world!


Using Jar Files

If you have a jar file that contains class definitions and you wish to use it, you can do the following:

  • To check contents of the jar, use the jar utility - it works a lot like tar
  • jar xf - expands (shows contents of) jar

Compile

To compile code mysource.java with a jar file called org.example.jar:

On Linux/Mac:

javac -cp '.:org.example.jar' mysource.java

On Windows:

javac -cp .;org.example.jar mysource.java

After this, you obtain the bytecode file mysource.class

Run

Now run the bytecode file:

java -cp '.:org.example.jar' mysource
java -cp .;org.example.jar mysource


Libraries

awesome-java repo on github [1]

immutables in Java (similar notation to javascript/d3) [2]

libgdx for 3d games in Java [3]

stanford core NLP in java [4]

legion of the bouncy castle [5]

  • lightweight crypto API in Java

apache shiro for session management (large enterprise or small mobile) [6]

selenium web browser test suite [7]

jsoup crawler and html parser [8]

crawler4j another crawler and html parser [9]