问题
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.
回答1:
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.
回答2:
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 )
回答3:
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
来源:https://stackoverflow.com/questions/13125782/how-to-detect-current-jsf-version