Wednesday, August 15, 2007

Eclipse : Running command line to EJB inside Eclipse

I'm running Eclipse Europa (the J2EE package).

See the previous post about running a command line Java program inside a DOS box and the million paths etc. you have to set up.

It's a lot easier to run it inside Eclipse by right clicking the application in the Package Explorer and selecting "Run As" / "Java Application".

(Note : JBoss needs to be started first by selecting the Server view inside the J2EE perspective , right click, "Start".)

You get this error in the console:

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


As per the previous post, the solution then was to add a path to the jndi.properties file:

set CLASSPATH=C:\JBoss-4.0.5.GA\server\default\conf;%CLASSPATH%

In Eclipse, however, go "Project Properties" / "Run/Debug Settings" / select the launch configuration / "Edit" / click on the "Classpath" tab / "Advanced: / "Add External Folder" and then browse to the jndi.properties folder as above and "OK" out.

That's it - Eclipse takes care of all the other stuff!

Enjoy!

No comments: