简体   繁体   English

字符串无法解析为类型 - Java RAD

[英]String cannot be resolved to a type - Java RAD

I've recently started developing in Java (coming from .Net).我最近开始用 Java 开发(来自 .Net)。 The IDE I am using is RAD 7.3.我使用的 IDE 是 RAD 7.3。

After importing a project, which I need to do some enhancements on, I am receiving this error:导入项目后,我需要对其进行一些增强,我收到此错误:

"String cannot be resolved to a type" “字符串无法解析为类型”

This applies to all variables of the String data type, as well as any methods that take string arguements.这适用于 String 数据类型的所有变量,以及任何采用字符串参数的方法。 I'm very inexperienced with Java so I'm not sure how to go about fixing this.我对 Java 非常缺乏经验,所以我不知道如何解决这个问题。 My guess is that it has something to do with the way RAD was installed, and that required libraries are missing.我的猜测是它与 RAD 的安装方式有关,并且缺少所需的库。 Again, not sure how to address that.同样,不知道如何解决这个问题。

Any help or guidance would be much appreciated!任何帮助或指导将不胜感激! Thank you谢谢

My guess is you miss the JRE Runtime Library in your project.我的猜测是您错过了项目中的 JRE 运行时库。 But this would cause all the java.* classes to generate this message!但这会导致所有 java.* 类生成此消息! Can you post your code so we can see what might be the problem?您可以发布您的代码以便我们看看可能是什么问题吗?

try doing :尝试做:

right-click on your project.右键单击您的项目。 ->properites ->java Build Path ->tab Librairies ->properites ->java Build Path ->tab 库

check if the JRE System Library is there.检查 JRE 系统库是否存在。

i am a beginner.我是初学者。 i am using Eclipse and got stuck at the Hello World code.我正在使用 Eclipse 并被困在 Hello World 代码中。 Got same error description and also error stating can't resolve 'system' .得到相同的错误描述和错误说明无法解析 'system'

After staying frustrated for few hours, as I checked JRE library path and stuff, I just Capitalized 'S' of ' string ' and ' system '.. and bang.. problem solved.在沮丧了几个小时之后,当我检查 JRE 库路径和内容时,我只是将“字符串”和“系统”的“S”大写……然后砰……问题解决了。 I hope this helps.我希望这有帮助。

I don't know if this helps anyone, but here I go.我不知道这是否对任何人有帮助,但我走了。 I had the same problem just now in Visual Studio Code (I am on Linux).我刚才在 Visual Studio Code 中遇到了同样的问题(我在 Linux 上)。 On my java.home , I had the options in my directory of:在我的java.home 上,我的目录中有以下选项:

  • /usr/lib/jvm/ java- 8 -openjdk-amd64 /usr/lib/jvm/ java- 8 -openjdk-amd64
  • /usr/lib/jvm/ java- 1.8.0 -openjkd-amd64 / usr / lib中/ JVM / Java的1.8.0 -openjkd-AMD64

I had the first one as default, but when I switched to the second one, it all started working properly.我将第一个作为默认设置,但是当我切换到第二个时,一切都开始正常工作。

Another way to solve this problem is in the following way.解决此问题的另一种方法是通过以下方式。

Right click on the project-->properties-->Java build path-->go to the library option右键项目-->属性-->Java构建路径-->进入库选项

and delete or remove the library that is in error, after this you select add library and download the library that you deleted and ready.并删除或删除错误的库,然后选择添加库并下载您删除并准备好的库。

您需要将字符串中的“s”大写。

error- string cannot be resolved to a type

Here in the declaring the method "string" in bold is lower case.这里在声明方法中以粗体显示的“字符串”是小写的。 Change string to upper case.将字符串更改为大写。 Example: public static string howManyPass(double grd1, double grd2) { }示例:公共静态字符串howManyPass(double grd1, double grd2) { }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM