JDK7中没有com.sun.tools.javac [英] No com.sun.tools.javac in JDK7

查看:73
本文介绍了JDK7中没有com.sun.tools.javac的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows 7 64位中使用JDK7和Eclipse Indiago.我将环境变量JAVA_HOME设置为F:\ JDK7并在路径中添加%JAVA_HOME%\ bin.这是我的示例代码:

I'm using JDK7 and Eclipse Indiago in Windows 7 64-bit. I set environment variable JAVA_HOME to F:\JDK7 and add %JAVA_HOME%\bin in path. It's my sample code:

com.sun.tools.javac.Main m1 = new com.sun.tools.javac.Main();
m1.compile(source);

我得到的错误:

com.sun.tools类型无法解析为 键入

Type com.sun.tools cannot be resolved to a type

为什么没有com.sun.tools?有什么问题吗?

Why there is no com.sun.tools ? What's the problem ?

推荐答案

似乎您正在使用Eclipse.默认情况下,Eclipse仅导入JRE jar,而不从JDK中导入.

It looks like you are using Eclipse. By default Eclipse only imports JRE jars, not the ones from the JDK.

解决方案1:

  1. 转到Eclipse首选项(在Windows上:Window-> Preferences)
  2. 打开首选项Java->已安装的JRE
  3. 选择您的JRE,然后按Edit
  4. 使用添加外部jar"来包含tools.jar(位于JDK_HOME/lib中)

解决方案2:

编辑您的项目构建路径并添加一个外部库:在JDK_HOME/lib中找到的tools.jar

Edit your project build path and add an external library: tools.jar found in JDK_HOME/lib

这篇关于JDK7中没有com.sun.tools.javac的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆