• ベストアンサー

Javaのエラーについてです

Javaプログラミングをしているのですが次のようなエラーが出てしまい、 原因が分からず困っています。 どなたが解決法をご存知の方がいらっしゃればご回答くださいませんでしょうか? String cannot be resolved to a type

  • Java
  • 回答数5
  • ありがとう数3

質問者が選んだベストアンサー

  • ベストアンサー
  • hirotn
  • ベストアンサー率59% (147/246)
回答No.4

>Eclipsのプログラムのアイコンの所に!マークが出ていますがこれとなにか関係があるのでしょうか? 関係あると思います。 ダブルクリック、あるいは右クリックしてメニューから何か選ぶと(Eclipse使っていないのでわからないのです。申し訳ありません。)、該当箇所に飛べると思います。 日本語化も可能なので、ご検討ください。 http://mergedoc.sourceforge.jp/

その他の回答 (4)

回答No.5

もうとっくに解決しているかな? 普通このエラーはプロジェクトに JRE ライブラリが指定されていないときに出ます。 Java Build Path の Library タブをチェックしてみてください。 そこに JRE System Library というのが有るはずですが、全くなかったり、 怪しげなエラーが出ていたら、ライブラリを設定しなおしてみてください。

teas_tea
質問者

お礼

ずいぶん遅くなりましてすいません。 エラーが結局消えずに諦めていました。 また時間のあるときに挑戦してみます。 ありがとうございました。

  • Tacosan
  • ベストアンサー率23% (3656/15482)
回答No.3

そのエラーメッセージと Eclipse で検索するといくつか引っかかるんだけど, それは確認した?

teas_tea
質問者

お礼

英語の文を読み取れずあきらめていました。 何とか考えてみたいと思います。 ご回答ありがとうございました。

  • hirotn
  • ベストアンサー率59% (147/246)
回答No.2

1)Eclipseをご利用ですか? 2)エラーの起きた箇所のソースを示していただければ、解決策を提示できるかと存じます。

teas_tea
質問者

補足

ご回答ありがとうございます。 (1)はい。Eclipseを使用しています。 (2)コードは長過ぎてどこを抜粋したらいいのか分からないのですが、とりあえずすべてのStringに対してエラーが出ています。 Eclipsのプログラムのアイコンの所に!マークが出ていますがこれとなにか関係があるのでしょうか?

noname#173931
noname#173931
回答No.1

本職のものではありませんが、それでもよければ回答させていただきます。 Internet Explorer 標準の検索エンジン Bing で 以下の記事を見つけました。 http://stackoverflow.com/questions/3877832/string-cannot-be-resolved-to-a-type この記事では String は頭文字が大文字ではじまるので 小文字で はじまる string は String の型に格納できない とあります。 teas_tea さんの質問文では String と大文字で始まっていますので これにあてはまるかわかりませんが、 型の宣言である String のつづりが間違えている、というものでは ないでしょうか? 違っていたらすいません。

teas_tea
質問者

お礼

Stringのつずりを調べてみたところ誤りはないようでした。 情報の少ない質問にも回答くださり、ありがとうございました。 もう少しプログラムと戦ってみます。

関連するQ&A

  • java eclipse キーボード入力

    今eclipse javaでキーボード入力のプログラムを作ってるのですが エラーがあって困ってるので誰かご指摘できる方が入ればよろしくお願いします。 以下ソース import java.io.BufferedReader; public class test1 { public static void main(String args[]){ System.out.println("文字を入力して下さい。"); Scanner scan = new Scanner(System.in);//エラー箇所「Scanner」二点 String str = scan.next(); System.out.println("最初のトークンは: "+ str); str = scan.next(); System.out.println("次のトークンは : "+ str); } } エラーメッセージは Exception in thread "main" java.lang.Error: Unresolved compilation problems: Scanner cannot be resolved to a type Scanner cannot be resolved to a type at test1.main(test1.java:8) エラーメッセージを日本語にすると「筋道の中に例外がある。未解決の編集物が問題」だと勝手に解釈してますがエラー対処がわかる方が入れば何卒よろしくお願いします。 カレントディレクトリは多分 HelloWorld/src/default package/test1です。 他にクラスは今の所ないので何が原因か掴めないでいますので 応えられる方がいればよろしくお願いします。

  • 三角形オブジェクト

    java 三角形のオブジェクトを作ってる最中なのですが エラーが多くて動きません。 自分が思うには他のクラス(Circle.java,Line.java,Point.java)と連携してないのかなと思ってます。 以下ソースです。 public class Sample70 { public static void main(String[] args) { Point o;//点オブジェクト Line line;//線lineオブジェクト Triangle triangle;//三角形triangleオブジェクト Circle circle;//円circleオブジェクト o = new Point(); line = new Line(); triangle = new Triangle(); circle = new Circle(); o.x = 0; o.y = 0; Point point = new Point(); point.x = 2; point.y = 3; line.p0 = point; point = new Point(); point.x = 4; point.y = 9; line.p1 = point; triangle.p0 = new Point(); triangle.p0.x = 3; triangle.p0.y = 9; triangle.p1 = new Point(); triangle.p1.x = 4; triangle.p1.y = 3; triangle.p2 = new Point(); triangle.p2.x = 4; triangle.p2.y = 6; circle.p0 = new Point(); circle.p0.x = 10; circle.p0.y = 10; circle.r = 1; System.out.println(o.x); System.out.println(line.p0.y); System.out.println(line.p1.x); System.out.println(triangle.p2.y); System.out.println(circle.r); } } エラーメッセージは Exception in thread "main" java.lang.Error: Unresolved compilation problems: x cannot be resolved or is not a field y cannot be resolved or is not a field x cannot be resolved or is not a field y cannot be resolved or is not a field p0 cannot be resolved or is not a field x cannot be resolved or is not a field y cannot be resolved or is not a field p1 cannot be resolved or is not a field p0 cannot be resolved or is not a field p0 cannot be resolved or is not a field p0 cannot be resolved or is not a field p1 cannot be resolved or is not a field p1 cannot be resolved or is not a field p1 cannot be resolved or is not a field p2 cannot be resolved or is not a field p2 cannot be resolved or is not a field p2 cannot be resolved or is not a field p0 cannot be resolved or is not a field p0 cannot be resolved or is not a field p0 cannot be resolved or is not a field r cannot be resolved or is not a field x cannot be resolved or is not a field p0 cannot be resolved or is not a field p1 cannot be resolved or is not a field p2 cannot be resolved or is not a field r cannot be resolved or is not a field at Sample70.main(Sample70.java:14) 多分フィールドがないよという意味なのかも知れませんが 中々実行がうまくいかず困ってます。 駄目出しで良いのでご教授頂ければと思います。 http://www.atmarkit.co.jp/ait/articles/0503/19/news020_2.html

    • ベストアンサー
    • Java
  • jspで、javaを呼び出すときの引数について

    jspの関数の中で、javaを呼び出しています。 その引数を、jsp内の数にしたいのです。 下記のように書くと、 idx cannot be resolved というエラーが出ます。 jspの中での数字を引数として使用する方法はありますか? function test(){ var idx = 5; <%=getHTML(idx) %>; }

  • java.lang.IllegalArgumentExceptionエラーについて

    いつも質問をさせていただいてます。 JAVAプログラミング初心者なんですが、下記のエラーがでて困っています。このエラーは`..nam0102'が無いと言ってるんでしょうか?? jp.co.intra_mart.common.aid.jsdk.javax.servlet.exception.ExtendedServletException: java.lang.IllegalArgumentException: request dispatcher url `..nam0102' must be absolute すみませんが、どなたか解決法をご教授ください。 struts/java/eclipseを使っています。

    • ベストアンサー
    • Java
  • jspのクラスのコンパイルエラー

    jspのクラスのコンパイルエラーが解決出来ず皆様にお力を借りたいと思っています 以前はjdk1.4のtomcat5の動かしていたプログラムを jdk1.7のtomcat7で動かさないといけなくなりました。 実行環境 tomcat7 jdk1.7 エラー内容 org.apache.jasper.JasperException: JSPのクラスをコンパイルできません: An error occurred at line: [16] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] The type AC10101_jsp must implement the inherited abstract method JspSourceDependent.getDependants() An error occurred at line: [22] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] The type Map is not generic; it cannot be parameterized with arguments <String, Long> An error occurred at line: [25] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] _jspx_dependants cannot be resolved to a variable An error occurred at line: [25] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] The type HashMap is not generic; it cannot be parameterized with arguments <String, Long> An error occurred at line: [26] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] _jspx_dependants cannot be resolved An error occurred at line: [26] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] The method valueOf(String) in the type Long is not applicable for the arguments (long) An error occurred at line: [27] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] _jspx_dependants cannot be resolved An error occurred at line: [27] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] The method valueOf(String) in the type Long is not applicable for the arguments (long) An error occurred at line: [28] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] _jspx_dependants cannot be resolved An error occurred at line: [28] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] The method valueOf(String) in the type Long is not applicable for the arguments (long) An error occurred at line: [29] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] _jspx_dependants cannot be resolved An error occurred at line: [29] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] The method valueOf(String) in the type Long is not applicable for the arguments (long) An error occurred at line: [30] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] _jspx_dependants cannot be resolved An error occurred at line: [30] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] The method valueOf(String) in the type Long is not applicable for the arguments (long) An error occurred at line: [31] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] _jspx_dependants cannot be resolved An error occurred at line: [31] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] The method valueOf(String) in the type Long is not applicable for the arguments (long) An error occurred at line: [45] in the generated java file: [E:\Tomcat 7.0\work\Catalina\localhost\test\org\apache\jsp\WEB_002dINF\pages\ac\AC10101_jsp.java] The type Map is not generic; it cannot be parameterized with a

  • java コンパイルエラー

    java コンパイルエラー java 初心者です。 簡単なプログラムを作りながら練習していたのですが、Exceptionクラスを継承して新しい例外を作る以下のプログラムで、コンパイルエラーとなり、解決できません。 class NewException extends Exception{ public NewException(){ super("エラー"); } } これを javac でコンパイルすると、 NewException.java:3: シンボルを見つけられません。 シンボル: コンストラクタ Exception(java.lang.String) 場所  : Exception の クラス super("エラー"); ^ エラー1個 と言われます。 これを読むと「Exception には String を引数にとるコンストラクタはないよ」と言われているように思えるのですが、そんなはずないのでは。。 もし原因がお分かりの方がいらしたら、ご教示いただけるとありがたいです。

    • ベストアンサー
    • Java
  • Eclipse3.5EEでJavaのコンパイルエラーメッセージ

    がでました。 以下の通りです。 Multiple markers at this line - The import javax.persistence.GenerationType.IDENTITY cannot be resolved - Syntax error, static imports are only available if source level is 1.5 これはどういう意味でしょうか? 特に「source level is 1.5」の意味を教えてください。 環境は Fedora11 Eclipse EE Developer 3.5 (Galileo) java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) Server VM (build 14.0-b16, mixed mode) です。

    • ベストアンサー
    • Java
  • androidアプリケーション実行エラー

    androidアプリを作成していて実行エラーが出ます。 your project contains error s please fix them before running your application 上記エラーメッセージで調べると、プロジェクトクリーンで 直ると出てくるのですが、実行しても直りません。 また問題タブのところには下記のエラーメッセージが出ています。 r cannot be resolved to a variable こちらも調べてみましたが解決策が見つからず困っています。 実施したことはアナログ時計の背景、 針の画像を指定したところでエラーが出ました。 開発環境は以下になります。 win XP eclips3.6.2 android SDK 2.3.3 (最初よくわからず4.03も落としてしまいました) よろしくお願いいたします。

  • java return文を指定できません。

    javaプログラミングのコンパイルエラーで、return文を指定できません。 を出てしまいます。いろんなことを試してのですがエラーを解決することができません。このエラーが出る原因として考えられることがあればどんな 些細なことでもかまいませんのでぜひ教えてください。お願いします。

  • PHPでのエラーについて

    Warning: mktime() expects parameter 4 to be long, string given in ~~ checkdate() expects parameter 1 to be long, string given in~~ というエラーは何が原因か誰か教えてください。。

    • 締切済み
    • PHP

専門家に質問してみよう