Follow the instruction to download java-8 lambda featured JDK & JRE.
Get the java 8 lambda package
Unzip and put it in some folder that you wanted or preferably at
Open terminal and set your
JAVA_HOME to point to your path and now execute the
javac commands to see if the libraries are good.
If you see the above versions, then you have set the path right and got the libraries working. Write any java 8 lambda program ( click here for sample ) and compile in the same “Terminal” session.
To set the JAVA_HOME permanently, create/open the
~/.bash_profile and set the JAVA_HOME path in it.
Compiling & Running Java 8 program
I’ve considered 3 choices here
- Using Terminal
- Using the Eclipse - External Tools features
- Using Apache Ant - Either in Eclipse or Terminal. I prefer Eclipse for a quick start.
Whatever you did above, are all is what you need to do to run it in terminal. And preferably have it in a shell script.
All you have to setup is these two items:
Now run javac and then followed by java.
Using Apache Ant
This is much more customizable and easier to run. Something similar to a Terminal approach, but much nicer.
Here is my an ant script - combines
If you are running this in a terminal, create a shell script to export the
ANT_HOME variable to the ANT path.
Running Ant in Eclipse
Make sure to update some settings in Eclipse preferences for Ant and configure the .
And here is a Hello world using a
lambda function to test.