The command line programs described below are on GitHub at https://github.com/gcronin/LearningJava.
Program 1: Parabola
Here's an example of the output; the parabola y = x^2 + 2x + 5 is equivalent to y = (x+1)^2 + 4 with a vertex at (-1, 4).
Program 2: Distance Formula
Program 3: Add Text to a File
A much more complex version of this program with user input can be found here (I didn't write it).
Using LeJos: Java for NXT:
You can program a LEGO NXT in Java. One of my students setup the compiler for me. Once LeJos is installed on your computer, you first need to turn .java files into .class files using "nxjc". Then you need to use "nxjlink" to create an "nxj" file from one of your class files. Finally, you use "nxjupload" to upload the .nxj file. In total, this series of commands will do the work for you:
nxjc *.java //create .class files from .java files
set /p mclass= "Please enter the name of the main class file: " %=% //chose a .class file
nxjlink -o linked.nxj %mclass% //create linked.nxj from the .class file
nxjupload -r *nxj //upload linked.nxj to the NXT
Here are a few Java programs for the NXT: