Class' java.io。'在JRE仿真库INTELLIJ IDEA中不存在

时间:2016-04-09 13:12:48

标签: gwt intellij-idea

我正在使用IntelliJ IDEA 15.0.4开发一个GWT项目。该项目编译并运行。但是IntelliJ一直告诉我JRE Emulation Library中没有java类文件。

请帮帮我!我的maven pom.xml中缺少什么东西吗?

以下是错误消息: enter image description here

enter image description here

我的pom.xml:

<properties>
   <maven.compiler.target>1.8</maven.compiler.target>
   <maven.compiler.source>1.8</maven.compiler.source>
</properties>

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <configuration>
      <source>1.8</source>
      <target>1.8</target>
   </configuration>
</plugin>

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <version>3.5.1</version>
   <configuration>
     <verbose>true</verbose>
     <fork>true</fork>
                       <executable>/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/javac</executable>
     <compilerVersion>1.8</compilerVersion>
   </configuration>
</plugin>

这是我的IntelliJ项目配置: enter image description here

enter image description here

Timesheet.gwt.xml

<?xml version="1.0" encoding="UTF-8"?>

<module rename-to='Timesheet'>
<!-- Inherit the core Web Toolkit stuff.                        -->
<inherits name='com.google.gwt.user.User' />
<inherits name="com.vaadin.polymer.Elements"/>

<!-- Inherit the default GWT style sheet.  You can change       -->
<!-- the theme of your GWT application by uncommenting          -->
<!-- any one of the following lines.                            -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->

<!-- Other module inherits                                      -->

<!-- Specify the app entry point class.                         -->
<entry-point class='com.campus.client.Timesheet' />

<!-- Specify the paths for translatable code                    -->
<source path='client' />
<source path='shared' />

<!--  <inherits name="com.google.gwt.user.theme.standard.Standard"/> -->
<inherits name="com.google.gwt.user.theme.clean.Clean"/>

<!-- For production, most teams prefer to set the default log level to `OFF` -->
<inherits name="com.allen_sauer.gwt.log.gwt-log-OFF" />

<!-- For development, a default of `DEBUG` is recommended -->
<!--  <inherits name="com.allen_sauer.gwt.log.gwt-log-DEBUG" /> -->


</module>

3 个答案:

答案 0 :(得分:1)

除非您拥有IntelliJ的完整版本,否则我强烈建议您使用Eclipse + GWT插件进行GWT开发。

这是GWT Jre模拟类的参考,这里的所有内容都适用于客户端: http://www.gwtproject.org/doc/latest/RefJreEmulation.html#Package_java_io

在您的特定情况下,似乎IntelliJ也找不到String类,这指出了比GWT相关更深层次的配置问题。

答案 1 :(得分:0)

当我在Arch Linux中安装Oracle JDK 9并将其用作项目SDK时,我似乎遇到了这个问题。卸载Oracle JDK 9并安装OpenJDK 8后,将其设置为项目SDK,不再发生错误。我想知道GWT是不是很好地支持Java 9或Oracle JDK。

另一个可能的错误原因是我可能错误地设置了SDK。首先,我将SDK路径指向/usr/lib/jvm/default-runtime,但稍后我将其更改为实际路径(/usr/lib/jvm/java-8-openjdk)。

答案 2 :(得分:0)

这将帮助您解决问题。.我遇到了同样的问题,并试图添加依赖项。

 <gwt.version>2.7.0</gwt.version>


 <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwt.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwt.version}</version>
        </dependency>