How to detect current JSF-Version?

假装没事ソ 提交于 2019-11-27 08:36:10

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.

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 )

steps

1: unzip javax.faces.jar (extract to a folder),go to extract folder\META-INF

2: in side META-INF ,open MANIFEST.MF.

3: search for Implementation-Version

for example : Implementation-Version: 2.1.6-SNAPSHOT

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!