java - 无法在 Windows 框中安装 WWW::HtmlUnit

标签 java perl classpath htmlunit

我正在尝试安装WWW::HTMLUnit在 Windows 7 上。我执行了以下步骤:

  1. 安装 Inline::Java 0.53
  2. 安装 WWW::HTMLUnit 0.15

在步骤 2 中,在 nmake 之后,我输入 nmake test 来测试模块,但失败了。这是输出:

C:\nmake test

Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

C:\Perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib\lib', 'blib\arch')" t/*.t
t/00_basic...........
t/00_basic...........NOK 1/1#   Failed test 'use WWW::HtmlUnit;'
#   at t/00_basic.t line 9.
#     Tried to use 'WWW::HtmlUnit'.
#     Error:  Class com.gargoylesoftware.htmlunit.WebClient not found at C:/Perl/site/lib/Inline/Java.pm line 619
# BEGIN failed--compilation aborted at (eval 4) line 2, <GEN7> line 4.
# Looks like you failed 1 test of 1.
t/00_basic...........dubious
        Test returned status 1 (wstat 256, 0x100)
DIED. FAILED test 1
        Failed 1/1 tests, 0.00% okay
t/01_hello...........Class com.gargoylesoftware.htmlunit.WebClient not found at C:/Perl/site/lib/Inline/Java.pm line 619
BEGIN failed--compilation aborted at t/01_hello.t line 4, <GEN7> line 4.
t/01_hello...........dubious
        Test returned status 26 (wstat 6656, 0x1a00)
t/02_hello_sweet.....dubious
        Test returned status 19 (wstat 4864, 0x1300)
t/03_clickhandler....Class com.gargoylesoftware.htmlunit.WebClient not found at C:/Perl/site/lib/Inline/Java.pm line 619
BEGIN failed--compilation aborted at t/03_clickhandler.t line 6, <GEN7> line 4.
t/03_clickhandler....dubious
        Test returned status 29 (wstat 7424, 0x1d00)
DIED. FAILED tests 1-8
        Failed 8/8 tests, 0.00% okay
Failed Test         Stat Wstat Total Fail  List of Failed
-------------------------------------------------------------------------------
t/00_basic.t           1   256     1    1  1
t/01_hello.t          26  6656    ??   ??  ??
t/02_hello_sweet.t    19  4864    ??   ??  ??
t/03_clickhandler.t   29  7424     8   16  1-8
Failed 4/4 test scripts. 9/9 subtests failed.
Files=4, Tests=9,  3 wallclock secs ( 0.00 cusr +  0.00 csys =  0.00 CPU)
Failed 4/4 test programs. 9/9 subtests failed.
NMAKE : fatal error U1077: 'C:\Perl\bin\perl.exe' : return code '0x1d'
Stop.

从上面的日志中,我可以看到:

class Error: com.gargoylesoftware.htmlunit.WebClient could not be found.

我不知道我错过了什么。 任何帮助将不胜感激。

谢谢。 明。

最佳答案

我找到了。 Unix 和 Windows 系统中的路径是不同的。 Unix 使用“:”作为分隔符,但 Windows 使用“;”。所以我所做的就是打开 HTMLUnit.pm 并将所有 ':' 更改为 ';'。 在 HTMLUnit 0.15 版本中,我对以下几行进行了更改: 第 78 行:

return join ';', map { "$jar_path/$_" } qw( # return join ':', map { "$jar_path/$_" } qw(

第 127 行:

$custom_jars = join(';', @{$parameters{'jars'}}); # $custom_jars = join(':', @{$parameters{'jars'}});

第 148 行:

CLASSPATH => collect_default_jars() . ";" . $custom_jars, # CLASSPATH => collect_default_jars() . ":" . $custom_jars,

它就像魔法一样。

关于java - 无法在 Windows 框中安装 WWW::HtmlUnit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5875554/

相关文章:

java - 在 Java 中评估后缀表达式

java - @WithMockUser 不带注释

java - 允许依赖项中的类从我的项目的类路径加载测试资源

Java 配置构建路径或 WEB-INF/lib 文件夹

java - 遍历动态JSON来读取每个子节点的属性

java - 什么标准规定 Java SE 的实现应该包含哪些类?

perl - 无法找到 perl 模块,即使 cpanm 声称它是最新的

perl - perl 中的简单并行处理

perl - 默认情况下,是否所有Mac OS X 10.6安装都安装了Perl?

java - 在 tomcat 类路径中包含 web-inf/lib 中的目录