Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import javax.faces library in Eclipse using JDK8?

Based on the advice to use JSF, the following sample would like to be run in order to learn more about JSF and to implement this technique into the servlet. However, a number of libraries is unable to be imported:

package tobedefinedservlet;

import javax.faces.bean.ManagedBean;

@ManagedBean
public class Hello {

    final String world = "Hello World!";

    public String getworld() {
        return world;
    }
}

javax.faces

The import javax.faces cannot be resolved

ManagedBean

ManagedBean cannot be resolved to a type

like image 878
030 Avatar asked Jun 28 '14 15:06

030


3 Answers

You have to include a JSF library like for example Mojarra in the classpath of your application.

First of all have a look at the Primefaces user guide (especially chapter 2.2). You can download e.g. Mojarra here and include the JAR or add the dependency to your POM.xml if you are using Maven. Hope that helps.

like image 121
LarsBauer Avatar answered Nov 17 '22 07:11

LarsBauer


If you're using maven for build automation, add the latest jsf-api dependency to your pom.xml:

<dependency>
    <groupId>javax.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.1</version>
</dependency>

Or the latest javax.faces-api implementation:

<dependency>
  <groupId>javax.faces</groupId>
  <artifactId>javax.faces-api</artifactId>
  <version>2.3</version>
</dependency>

However, note that JSF is integrated into most Java EE application servers, such as JBoss.

See also this answer.

like image 37
Woodchuck Avatar answered Nov 17 '22 07:11

Woodchuck


in my case ...I went to project properties and in the search engine I wrote facets ... I went to the right of the window and selected the runtime tab and select wildfly ... then apply and apply and close and solve ...

like image 1
Henry Vargas Guevara Avatar answered Nov 17 '22 07:11

Henry Vargas Guevara