Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect current JSF-Version?

I am developing a jsf-webapp and now I need to know what JSF-Version I am using? Where can I look this up? Thanks in advance.

like image 981
Jochen Avatar asked Oct 29 '12 16:10

Jochen


2 Answers

Programmatically, you mean? You can get it from Package#getImplementationVersion().

String version = FacesContext.class.getPackage().getImplementationVersion(); 

There are by the way also getImplementationVendor() and getImplementationTitle() methods. You might want to use it as well in order to distinguish the vendor (MyFaces or Mojarra, for example).

Or do you mean manually? Just look in /META-INF/MANIFEST.MF file of the JSF impl JAR file. You can extract the JAR file with a ZIP tool. It's the Implementation-Version entry of the manifest file.

like image 198
BalusC Avatar answered Sep 21 '22 17:09

BalusC


For me it wasn’t working with a WebSphere Server, so I followed the comment of peater:

System.out.println("JSF API Location: " + FacesContext.class.getProtectionDomain().getCodeSource()); System.out.println("JSF Impl Location: " + Facelet.class.getProtectionDomain().getCodeSource()); 

It showed me the version in the filename of the library:

JSF API Location: (file:/C:/workspaces/spielwiese/wlp/dev/api/spec/com.ibm.websphere.javaee.jsf.2.2_1.0.18.jar )

JSF Impl Location: (file:/C:/workspaces/spielwiese/wlp/dev/api/spec/com.ibm.websphere.javaee.jsf.2.2_1.0.18.jar )

like image 21
Hannes Schneidermayer Avatar answered Sep 24 '22 17:09

Hannes Schneidermayer