java - run web application - error: package javax.faces.bean does not exist -


i'm newly @ web application. tried run easy web application program. after running

javac -d web-inf/classes web-inf/classes/bigjava/*.java  

i had output:

nazar_art@nazar-desctop:~/desktop/big java/bj4_code/ch24/time$ javac -d web-inf/classes web-inf/classes/bigjava/*.java web-inf/classes/bigjava/timebean.java:6: error: package javax.faces.bean not exist import javax.faces.bean.managedbean;                        ^ web-inf/classes/bigjava/timebean.java:7: error: package javax.faces.bean not exist import javax.faces.bean.sessionscoped;                        ^ web-inf/classes/bigjava/timebean.java:9: error: cannot find symbol @managedbean  ^   symbol: class managedbean web-inf/classes/bigjava/timebean.java:10: error: cannot find symbol @sessionscoped  ^   symbol: class sessionscoped 4 errors 

code:

package bigjava;  import java.text.dateformat; import java.util.date; import java.util.timezone; import javax.faces.bean.managedbean; import javax.faces.bean.sessionscoped;  @managedbean @sessionscoped public class timebean {    private dateformat timeformatter;     /**       initializes formatter.    */    public timebean()    {       timeformatter = dateformat.gettimeinstance();    }     /**       read-only time property.       @return formatted time    */    public string gettime()    {       date time = new date();       string timestring = timeformatter.format(time);       return timestring;    } } 

all class files placed inside web-inf/classes directory. index.html web-inf , contained:

<?xml version="1.0" encoding="utf-8"?> <html xmlns="http://www.w3.org/1999/xhtml"    xmlns:h="http://java.sun.com/jsf/html">    <h:head>       <title>the time application</title>    </h:head>    <h:body>       <h:form>          <p>                        current time #{timebean.time}          </p>       </h:form>    </h:body> </html> 

web.xml @ same level classes , contains:

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xmlns="http://java.sun.com/xml/ns/javaee"    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"    xsi:schemalocation="http://java.sun.com/xml/ns/javaee        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"    version="2.5">    <servlet>       <servlet-name>faces servlet</servlet-name>       <servlet-class>javax.faces.webapp.facesservlet</servlet-class>    </servlet>    <servlet-mapping>       <servlet-name>faces servlet</servlet-name>       <url-pattern>/faces/*</url-pattern>    </servlet-mapping>    <welcome-file-list>       <welcome-file>faces/index.xhtml</welcome-file>    </welcome-file-list>    <context-param>       <param-name>javax.faces.project_stage</param-name>       <param-value>development</param-value>    </context-param> </web-app> 

i maybe lose couldn’t figure out exactly.

any suggestions?

you have add javax.faces.api jar file project. can find library here.

after downloading file, have import project , add artifact.

refer link error “package javax.faces.bean not exist”


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -