This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm still confused with how to interact with the JNDI, here is my simple code to display hello, so could someone tell me what's wrong ?
1 - error message tha I got
Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
The problem is the JNDI lookup. You have to know the right lookup name and you most probably have to specify some system parameters which tell the client for example on which IP address and port it may connect to a JNDI provider.
Both of these things may depend on the application server (at least with EJB 3.0) you're using! So perhaps you can tell us which server it is or you can search yourself on the internet which are the correct settings for your server!
from the header of your code fragments I guess you used NetBeans to create the project. Perhaps it's the easiest way to understand the problem by having a look at this tutorial. In particular the section "Creating a Java Stand-Alone Client" will be helpful as it describes how to setup the JNDI parameters with a "jndi.properties" file on the classpath ;-)
Additionally it could be useful for debugging to show what's in the JNDI lookup of Glassfish as described here.