编译时错误 - 在导入中找不到符号 java.io.BufferedReader;
Compile time error - can't find symbol in import java.io.BufferedReader;
将 Java 与 NetBeans 一起使用 IDE 我有一个程序,在我编译它之前不会给我任何错误或警告,但它会告诉我:
error: cannot find symbol
import java.io.BufferedReader;
symbol: class BufferedReader
location: package java.io
1 error
(底部完全错误)
为了给出一个完整的示例,我将使用从我正在使用的插件 CODAPPS 生成的模板,我所做的只是添加行 import java.io.BufferedReader;
。示例中未使用导入,但错误与我的程序相同:
StateMachine.java
/**
* Your application code goes here
*/
package userclasses;
import java.io.BufferedReader;
import generated.StateMachineBase;
import com.codename1.ui.*;
import com.codename1.ui.events.*;
import com.codename1.ui.util.Resources;
/**
*
* @author Your name here
*/
public class StateMachine extends StateMachineBase {
public StateMachine(String resFile) {
super(resFile);
// do not modify, write code in initVars and initialize class members there,
// the constructor might be invoked too late due to race conditions that might occur
}
/**
* this method should be used to initialize variables instead of
* the constructor/class scope to avoid race conditions
*/
protected void initVars(Resources res) {
}
}
错误:
Updating property file: C:\Users\hackr\Documents\NetBeansProjects\CodenameOne Hello World\build\built-jar.properties
Compile is forcing compliance to the supported API's/features for maximum device compatibility. This allows smaller
code size and wider device support
Compiling 3 source files to C:\Users\hackr\Documents\NetBeansProjects\CodenameOne Hello World\build\tmp
C:\Users\hackr\Documents\NetBeansProjects\CodenameOne Hello World\src\userclasses\StateMachine.java:6: error: cannot find symbol
import java.io.BufferedReader;
symbol: class BufferedReader
location: package java.io
1 error
在NetBeans中点击绿色"play"按钮生成的编译程序的命令是:
ant -f "C:\Users\hackr\Documents\NetBeansProjects\CodenameOne Hello World" -Dnb.internal.action.name=run run
查看 CODEAPP Java 文档 on Codename One's CODAPPS site 后,一切都清楚了:您不是针对任何成熟的 Java JDK 进行开发或编译,而是一个受限制的子集,通过一些用于移动应用程序的内容得到增强。
您不能使用 java.io.BufferedReader
。使用 link 中的 Java 文档查看您可能使用的内容。
如果您认为值得麻烦,您可以掠夺 JDK 源 - 如果您还没有下载所有 JDK 源,grepcode 会为您找到它。或者看看它,从中学习,然后自己动手 - 你可能不需要 class.
的所有功能
将 Java 与 NetBeans 一起使用 IDE 我有一个程序,在我编译它之前不会给我任何错误或警告,但它会告诉我:
error: cannot find symbol
import java.io.BufferedReader;
symbol: class BufferedReader
location: package java.io
1 error
(底部完全错误)
为了给出一个完整的示例,我将使用从我正在使用的插件 CODAPPS 生成的模板,我所做的只是添加行 import java.io.BufferedReader;
。示例中未使用导入,但错误与我的程序相同:
StateMachine.java
/**
* Your application code goes here
*/
package userclasses;
import java.io.BufferedReader;
import generated.StateMachineBase;
import com.codename1.ui.*;
import com.codename1.ui.events.*;
import com.codename1.ui.util.Resources;
/**
*
* @author Your name here
*/
public class StateMachine extends StateMachineBase {
public StateMachine(String resFile) {
super(resFile);
// do not modify, write code in initVars and initialize class members there,
// the constructor might be invoked too late due to race conditions that might occur
}
/**
* this method should be used to initialize variables instead of
* the constructor/class scope to avoid race conditions
*/
protected void initVars(Resources res) {
}
}
错误:
Updating property file: C:\Users\hackr\Documents\NetBeansProjects\CodenameOne Hello World\build\built-jar.properties
Compile is forcing compliance to the supported API's/features for maximum device compatibility. This allows smaller
code size and wider device support
Compiling 3 source files to C:\Users\hackr\Documents\NetBeansProjects\CodenameOne Hello World\build\tmp
C:\Users\hackr\Documents\NetBeansProjects\CodenameOne Hello World\src\userclasses\StateMachine.java:6: error: cannot find symbol
import java.io.BufferedReader;
symbol: class BufferedReader
location: package java.io
1 error
在NetBeans中点击绿色"play"按钮生成的编译程序的命令是:
ant -f "C:\Users\hackr\Documents\NetBeansProjects\CodenameOne Hello World" -Dnb.internal.action.name=run run
查看 CODEAPP Java 文档 on Codename One's CODAPPS site 后,一切都清楚了:您不是针对任何成熟的 Java JDK 进行开发或编译,而是一个受限制的子集,通过一些用于移动应用程序的内容得到增强。
您不能使用 java.io.BufferedReader
。使用 link 中的 Java 文档查看您可能使用的内容。
如果您认为值得麻烦,您可以掠夺 JDK 源 - 如果您还没有下载所有 JDK 源,grepcode 会为您找到它。或者看看它,从中学习,然后自己动手 - 你可能不需要 class.
的所有功能