【问题】
MingW的MSYS环境下,运行FOP,结果出错了:
=============================== generating pdf ============================== fop --execdebug -c /E/Dev_Root/docbook/dev/config/fop/conf/fop.xconf ../output/fo/docbook_dev_note.fo -pdf ../output/pdf /docbook_dev_note.pdf exec "C:\Program Files (x86)\Java\jre7/bin/java" -classpath "E:\Dev_Root\docbook\tools\fop-1.0/build/fop.jar;E:\Dev_Root \docbook\tools\fop-1.0/build/fop-sandbox.jar;E:\Dev_Root\docbook\tools\fop-1.0/build/fop-hyph.jar;" org.apache.fop.cli.M ain "-c" "/E/Dev_Root/docbook/dev/config/fop/conf/fop.xconf" "../output/fo/docbook_dev_note.fo" "-pdf" "../output/pdf/do cbook_dev_note.pdf" Unable to start FOP: java.lang.RuntimeException: fop.jar not found in directory: e:\Dev_Root\docbook\dev\books\docbook_dev_note\src (or below ) at org.apache.fop.cli.Main.getJARList(Main.java:65) at org.apache.fop.cli.Main.startFOPWithDynamicClasspath(Main.java:125) at org.apache.fop.cli.Main.main(Main.java:207)
【解决过程】
1. 尝试去将FOP_HOME从:
E:\Dev_Root\docbook\tools\fop-1.0
改为MSYS的路径
/E/Dev_Root/docbook/tools/fop-1.0
然后重启MingW再去测试,结果更加错误的了:
Administrator@NYBDHB7EB3XEHP6 /e/Dev_Root/docbook/dev/books/docbook_dev_note/src $ make pdf =============================== generating pdf ============================== fop --execdebug -c /E/Dev_Root/docbook/dev/config/fop/conf/fop.xconf ../output/fo/docbook_dev_note.fo -pdf ../output/pdf /docbook_dev_note.pdf exec "C:\Program Files (x86)\Java\jre7/bin/java" -classpath "/E/Dev_Root/docbook/tools/fop-1.0/lib/xmlgraphics-commons-1 .4.jar;/E/Dev_Root/docbook/tools/fop-1.0/lib/xml-apis-ext-1.3.04.jar;/E/Dev_Root/docbook/tools/fop-1.0/lib/xml-apis-1.3. 04.jar;/E/Dev_Root/docbook/tools/fop-1.0/lib/xercesImpl-2.7.1.jar;/E/Dev_Root/docbook/tools/fop-1.0/lib/xalan-2.7.0.jar; /E/Dev_Root/docbook/tools/fop-1.0/lib/serializer-2.7.0.jar;/E/Dev_Root/docbook/tools/fop-1.0/lib/fop-hyph.jar;/E/Dev_Roo t/docbook/tools/fop-1.0/lib/commons-logging-1.0.4.jar;/E/Dev_Root/docbook/tools/fop-1.0/lib/commons-io-1.3.1.jar;/E/Dev_ Root/docbook/tools/fop-1.0/lib/batik-all-1.7.jar;/E/Dev_Root/docbook/tools/fop-1.0/lib/avalon-framework-4.2.0.jar;/E/Dev _Root/docbook/tools/fop-1.0/build/fop.jar;/E/Dev_Root/docbook/tools/fop-1.0/build/fop-sandbox.jar;/E/Dev_Root/docbook/to ols/fop-1.0/build/fop-hyph.jar;" org.apache.fop.cli.Main "-c" "/E/Dev_Root/docbook/dev/config/fop/conf/fop.xconf" "../ou tput/fo/docbook_dev_note.fo" "-pdf" "../output/pdf/docbook_dev_note.pdf" 错误: 找不到或无法加载主类 org.apache.fop.cli.Main make: *** [../output/pdf/docbook_dev_note.pdf] Error 1
2. 看了半天,感觉还是先要把之前在这里:
对于fop的改动再改回来,即把:
#LCP_TEMP=`cygpath –path –unix "$LOCALCLASSPATH"`
# for cygpath has bug, so use follow workaround
# edit by admin AT crifan DOT com
LCP_TEMP=`cygpath –path –$format "$LOCALCLASSPATH"`
LCP_TEMP=`cygpath –path –unix "$LCP_TEMP"`
再改回:
LCP_TEMP=`cygpath –path –unix "$LOCALCLASSPATH"`
# for cygpath has bug, so use follow workaround
# edit by admin AT crifan DOT com
#LCP_TEMP=`cygpath –path –$format "$LOCALCLASSPATH"`
#LCP_TEMP=`cygpath –path –unix "$LCP_TEMP"`
看看结果如何。结果却是问题依旧。
3. 最后,还是感觉让java去执行/E/xxx的MSYS路径,明显不太多,所以还是改回去:
把FOP_HOME的/E/Dev_Root/docbook/tools/fop-1.0改回E:\Dev_Root\docbook\tools\fop-1.0
不过,倒也可以先试试:
E:/Dev_Root/docbook/tools/fop-1.0
的效果如何。
结果无意中,竟然就正常执行了,真是很无语:
=============================== generating pdf ============================== fop --execdebug -c /E/Dev_Root/docbook/dev/config/fop/conf/fop.xconf ../output/fo/docbook_dev_note.fo -pdf ../output/pdf /docbook_dev_note.pdf exec "C:\Program Files (x86)\Java\jre7/bin/java" -classpath "E:/Dev_Root/docbook/tools/fop-1.0/lib/xmlgraphics-commons-1 .4.jar;E:/Dev_Root/docbook/tools/fop-1.0/lib/xml-apis-ext-1.3.04.jar;E:/Dev_Root/docbook/tools/fop-1.0/lib/xml-apis-1.3. 04.jar;E:/Dev_Root/docbook/tools/fop-1.0/lib/xercesImpl-2.7.1.jar;E:/Dev_Root/docbook/tools/fop-1.0/lib/xalan-2.7.0.jar; E:/Dev_Root/docbook/tools/fop-1.0/lib/serializer-2.7.0.jar;E:/Dev_Root/docbook/tools/fop-1.0/lib/fop-hyph.jar;E:/Dev_Roo t/docbook/tools/fop-1.0/lib/commons-logging-1.0.4.jar;E:/Dev_Root/docbook/tools/fop-1.0/lib/commons-io-1.3.1.jar;E:/Dev_ Root/docbook/tools/fop-1.0/lib/batik-all-1.7.jar;E:/Dev_Root/docbook/tools/fop-1.0/lib/avalon-framework-4.2.0.jar;E:/Dev _Root/docbook/tools/fop-1.0/build/fop.jar;E:/Dev_Root/docbook/tools/fop-1.0/build/fop-sandbox.jar;E:/Dev_Root/docbook/to ols/fop-1.0/build/fop-hyph.jar;" org.apache.fop.cli.Main "-c" "/E/Dev_Root/docbook/dev/config/fop/conf/fop.xconf" "../ou tput/fo/docbook_dev_note.fo" "-pdf" "../output/pdf/docbook_dev_note.pdf" 十月 01, 2012 11:48:21 下午 org.apache.fop.apps.FopFactoryConfigurator configure INFO: Default page-height set to: 11in 十月 01, 2012 11:48:21 下午 org.apache.fop.apps.FopFactoryConfigurator configure
4. 回头再去刚刚才的改动,之所以可以让其正常工作,主要是里面的所有的路径中的分隔符,都是Unix中的斜杠,而非开始的斜杠和反斜杠的混合体。
【总结】
MingW/MSYS环境下,运行FOP出错Unable to start FOP, java.lang.RuntimeException: fop.jar not found in directory的
原因是FOP_HOME的路径设置有误。
解决办法是:
把FOP_HOME从
从windows(cmd)类型的路径:
E:\Dev_Root\docbook\tools\fop-1.0
改为Unix类型的路径:
E:/Dev_Root/docbook/tools/fop-1.0
如此,FOP(在MingW的环境下)就可以正常识别对应的路径了。
注意,也不能改为MingW的路径:
/E/Dev_Root/docbook/tools/fop-1.0
否则还是会出现另外的错误”找不到或无法加载主类 org.apache.fop.cli.Main “的。
转载请注明:在路上 » 【已解决】Ming/MSYS下运行FOP出错:Unable to start FOP, java.lang.RuntimeException: fop.jar not found in directory