一位同事为我正在处理的Android应用程序提供了第二个包,并且在类中导入了几个“java.awt”和“javax.swing”导入,这些导入全部用红色“x”标记。
Eclipse(Mars.2,4.5.2)已经知道安装了哪些Java版本(Window - Preferences - Java - 安装的JRE,“jdk1.8.0_161”旁边有一个复选标记),我只是检查了JAVA_HOME环境变量是否仍然在那里(它是)。 为了解决这个问题,我仍然需要将JRE系统库(1.8.0 v161)添加到项目的构建路径中。
实际的问题是:每次我重新启动Eclipse时,红色的“x”都回来了,我必须再次添加Java。
我如何避免Eclipse忘记库?
编辑:我的项目的类路径说:
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="gen"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin/classes"/> </classpath>A co-worker gave me a second package for an Android app I'm working on and there are a couple of "java.awt" and "javax.swing" imports in the classes, which were all marked with red "x".
Eclipse (Mars.2, 4.5.2) already knows what Java versions are installed (Window - Preferences - Java - Installed JREs, "jdk1.8.0_161" has a checkmark next to it) and I just checked if the JAVA_HOME environment variable is still there (which it is). To fix the problem, I still had to add a JRE system library (1.8.0 v161) to the project's build path.
The actual problem is: Every time I restart Eclipse, the red "x" are back and I have to add Java again.
How can I keep Eclipse from forgetting the library?
Edit: The classpath for my project says:
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="gen"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin/classes"/> </classpath>最满意答案
java.awt和javax.swing都不是Android API的一部分(因为Android使用自己的UI工具包)。 您可以通过添加外部JAR ...将JRE / JDK的lib/rt.jar 添加到您的Java构建路径中,但这是一个肮脏的窍门。
Neither java.awt nor javax.swing are part of the Android API (because Android uses its own UI toolkit). You can add a JRE/JDK's lib/rt.jar via Add External JARs... to your Java Build Path, but that's a dirty trick.
更多推荐
发布评论