Java 包不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7361199/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 19:39:24  来源:igfitidea点击:

Java package does not exist

javaantpackageenvironment-variables

提问by Edheene

I am starting to work on legacy project and fighting now with running it on my computer. I have imported it yesterday and everything worked fine, project did build and everyone was happy. Then I had to install some additional software and had some problems with java jdk and jre paths, but I managed to finish that task and I got back to building the project and I couldn't do it. I have not changed any file in the project, nor any project configuration (I'm using eclipse and build with ant) only changes in system environment were made. It also builds in other team member environment, so it's not the code itself.

我开始处理遗留项目,现在正在努力在我的计算机上运行它。我昨天导入了它,一切正常,项目确实建立了,每个人都很高兴。然后我不得不安装一些额外的软件,并且在 java jdk 和 jre 路径方面遇到了一些问题,但我设法完成了这项任务,然后我又回到了构建项目的过程中,但我无法做到。我没有更改项目中的任何文件,也没有更改任何项目配置(我正在使用 eclipse 并使用 ant 构建),只是在系统环境中进行了更改。它也在其他团队成员环境中构建,所以它不是代码本身。

error message I get looks like this:

我收到的错误消息如下所示:

[javac] C:\Users\bilskluc\virtualdisk\blah\xyz\packages\radius\src\com\blah\wfc\radiusinput\RadiusHostEntry.java:9: package com.blah.devkit.exception does not exist
[javac] import com.blah.devkit.exception.DRException;
[javac]                                         ^
[javac] C:\Users\bilskluc\virtualdisk\blah\xyz\packages\radius\src\com\blah\wfc\radiusinput\RadiusHostEntry.java:10: package com.blah.devkit.storable does not exist
[javac] import com.blah.devkit.storable.DRAbstractStorable;
[javac]                                        ^

and so on. It looks exactly the same in eclipse an when I run it from the console. ant packages used are imported with the project and pointed explicitly, also most important env variables are set from configuration file before running the build and the configuration file did not change.

等等。当我从控制台运行它时,它在 eclipse 中看起来完全相同。使用的 ant 包与项目一起导入并明确指出,最重要的 env 变量也是在运行构建之前从配置文件设置的,并且配置文件没有更改。

Mentioned packages and classes are in a .jar file included in project.

提到的包和类位于项目中包含的 .jar 文件中。

Did anyone have a similar problem? I have checked everything I could think of. To reduce risk that I changed something I removed all code and download it from svn again (and checked that there were no commits in last few days).

有没有人有类似的问题?我已经检查了我能想到的一切。为了降低我更改某些内容的风险,我删除了所有代码并再次从 svn 下载它(并检查过去几天是否没有提交)。

Maybe someone has an idea where I should look for some system configuration changes that could cause this problem.

也许有人知道我应该在哪里寻找可能导致此问题的一些系统配置更改。

EDIT

编辑

those two libraries are mentioned in .classpath file

.classpath 文件中提到了这两个库

<classpathentry kind="lib" path="blah/lib/devkit.jar">
    <attributes>
        <attribute name="javadoc_location" value="jar:platform:/resource/MZ-package-radius/blah/lib/devkit_javadoc.jar!/javadoc"/>
    </attributes>
</classpathentry>
<classpathentry kind="lib" path="blah/lib/picostart.jar"/>

but I don't know ant very well so I don't know if it uses this file to determine classpath or does it use any other setting

但我不太了解 ant 所以我不知道它是使用这个文件来确定类路径还是使用任何其他设置

回答by Paul

Assuming you have your class path set up in your ANT script:

假设您在 ANT 脚本中设置了类路径:

<path id="compile.classpath">
    ...
</path>

You can output the classpath being used by your ANT script by putting something like this inside your target:

您可以通过在目标中放置如下内容来输出 ANT 脚本正在使用的类路径:

<property name="myclasspath" refid="compile.classpath"/>
  <echo message="Classpath = ${myclasspath}"/>

回答by Matt Gibson

I just figured out a solution that works for me. My libraries were in a "lib" directory. Oddly, movingthem to a "libs" directory, re-adding them to the build path in Eclipse, and then updating the project for Ant (android update project --path .) magically started things working again. Perhaps the "libs" folder is special, and it has to be called exactly that?

我刚刚想出了一个对我有用的解决方案。我的库位于“lib”目录中。奇怪的是,它们移动到“libs”目录,将它们重新添加到 Eclipse 中的构建路径,然后为 Ant ( android update project --path .)更新项目,神奇地重新开始工作。也许“libs”文件夹很特殊,必须准确地调用它?

回答by zygimantus

You can put your jars into build/jar/ folder and then use this path:

您可以将 jars 放入 build/jar/ 文件夹,然后使用以下路径:

<path id="mypath">
    <fileset dir="build/lib">
      <include name="*.jar" />
    </fileset>
</path>