【问题标题】:installing apache.commons.lang on MAC jEdit在 MAC jEdit 上安装 apache.commons.lang
【发布时间】:2014-11-28 11:41:40
【问题描述】:

我需要帮助在 Mac jEdit 上安装 Apache.Commons.Lang

采取的步骤:

  1. 我需要帮助在 Mac jEdit 上安装 Apache.Commons.Lang。
  2. 我已经从 Apache 下载了文件。
  3. 我尝试在许多位置复制“commons-lang3-3.3.2.jar”,但无济于事。

我尝试使用这个简单的文件测试我的安装:

import org.apache.commons.lang3.StringUtils;

public class TestOne {
    public static void main(String[] args) {
            String text = "Hello World";
            System.out.println(StringUtils.reverse(text));
    }

}

我收到以下错误:

TestOne.java:1: error: package org.apache.commons.lang3 does not exist
import org.apache.commons.lang3.StringUtils;

                               ^

 TestOne.java:6: error: cannot find symbol
                System.out.println(StringUtils.reverse(text));
                                   ^



 symbol:   variable StringUtils
  location: class TestOne

2 个错误

感谢您的帮助/指导!

(我的第一篇文章)

【问题讨论】:

  • 你把jar添加到classpath了吗?
  • 你如何编译你的代码?您使用 ant 或 JCompiler(JEdit 插件)还是在 JEdit 之外编译?
  • 谢谢大家,抱歉回复晚了。我在我的 MAC 上使用终端进行编译。
  • 我还没有将 jar 添加到类路径中。我不知道该怎么做。你能指出我正确的方向吗?再次感谢

标签: java macos installation jedit apache-commons-lang


【解决方案1】:

来自jedit manual

Java 类路径

1. can define CLASSPATH within the Ant build file if it is being used
2. JCompiler has its own CLASSPATH settings (and SOURCEPATH) which are defined in the plugin's options panel
3. No clean way to have different CLASSPATHs for different projects; there is an incomplete migration to a mechanism for doing this. Ant is the easiest method right now

你没有提到蚂蚁,所以我假设 1 出来了。我会编辑以防你使用它。

JCompiler 有一个类路径设置(查找 JCompiler 插件的选项)。将 jar 文件添加到那里的类路径中。

如果你手动编译,你需要编译使用:(see this for documentation) 视窗: javac -classpath path_to_jar;path_to_otherjar;path_to_folder someFile.java mac/linux: javac -classpath path_to_jar:path_to_otherjar:path_to_folder someFile.java

在 osx/linux 上,你用 : (冒号) not ; 分隔类路径元素(分号)

【讨论】:

  • 嘿Joeblade,我没有使用Ant,我是编码新手,所以我不知道如何完成。如果它是您推荐的最简单的方法,我可以开始查找。
  • 嗯,你目前正在以某种方式编译它,否则你不会得到错误。因此,我建议您了解目前的编译方式。还要检查答案中的文档链接。手动编译的最基本方法是转到您的源文件夹(假设您的 java 文件位于包 com.abc 和磁盘站点上 c:/dev/project/src/com/abc/Test.java 然后转到 c :/dev/project/src 并在那里运行 javac -classpath a:b:c com.abc.Test.java 它应该可以编译。使用 a:b:c 作为 jar 文件的路径
  • 谢谢乔,我在 MAC 上使用终端进行编译,您在包含我的 java 文件的文件中是正确的。但是,我尝试了您的解决方案,但出现错误: javac: no source files Usage: javac use -help for a list of possible options 但是,我可以编译和执行其他未使用的文件common.lang 我正在查看您列出的文档,我正在根据您的指导制定解决方案...非常感谢!
【解决方案2】:

在把我的头撞到墙上几天之后,我安装了 Eclipse。
更干净的设置。

感谢所有帮助过的人!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-20
    • 2018-10-12
    • 2014-06-05
    • 2013-02-18
    • 2019-08-17
    • 2017-05-09
    • 2013-07-09
    相关资源
    最近更新 更多