Cannot import javax.ejb.* packages

前端 未结 2 1040
情歌与酒
情歌与酒 2020-12-25 15:00

I am having trouble in building an EJB session bean.

The following packages cannot be found:

import javax.ejb.LocalBean;
i         


        
2条回答
  •  情歌与酒
    2020-12-25 15:19

    The EJB API is found in the JavaEE libraries which are, as you correctly pointed out, distributed with the j2ee.jar library. If you're using Eclipse, its classpath may be pointing to the standard Java libraries and not the Enterprise libraries. You can try two things:

    1. Compile and run your code from the command line. Set %JAVA_HOME% to point to the installation directory of java_ee_sdk-7-windows-ml and add %JAVA_HOME%/bin to the %PATH%.
    2. Find the Enterprise library and add it to your CLASSPATH in Eclipse. The CLASSPATH is set by going to the project properties and selecting the option "Add an external library/jar file". Add any jar files found in the EE installation directory to the build path.

提交回复
热议问题