2012-01-24 9 views
-2

Javaクラスをコンパイルするが、私はjavaファイルエラー私は、CMDプロンプトからJavaアプリケーションを実行しようとしています

cannot find symbol 
    symbol : variable TextIO 
    location : class Interest2 

はどこ私はここで間違っつもりだと言って、エラーを取得しておく一方で?

+0

正確なエラーを投稿できますか? –

+0

クラスパスが正しくありません。詳細については、[このクラスパスのドキュメント](http://docs.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html)を参照してください。それは知る価値がある。 –

+0

my classpathがmy javaファイルのある場所に設定されています – ben

答えて

0

プログラムが格納されているディレクトリにTextIO.classファイルを追加しましたか? TextIOクラスをそこで取得することはできないようです。

TextIOクラスは、Javaの標準ライブラリにはありません。だから自分でプロジェクトに入れる必要があります。これは標準クラスではありません。TextIO.javaを使用するプログラムにTextIO.javaを追加することを忘れないでください。

​​をTextIOで実行しようとしています。

したがって、Interestというフォルダを作成し、TextIO.javafrom hereを置き、Interest2.javaを同じフォルダに配置します。

TextIO.javaを使用してjavac -Xlint TextIO.javaをコンパイルした後、プログラムを実行します。あなたが最初の名前「TextIOでクラスファイルを作成する必要があります

http://www.faqs.org/docs/javap/source/TextIO.java

+0

私は..私のディレクトリ=ワークスペースを持っていると思いますか? – ben

+0

eclipseやide以外で作業している場合は、 'TextIO' Javaファイルを現在のプロジェクトにインポートする必要があります。 http://math.hws.edu/eck/cs124/f05/labs/lab4/の操作方法を見てください。 – RanRag

+0

また、 'import class file eclipse'または' import external java file eclipse as dependency'にgoogleを使ってください。 – RanRag

0

は、次のURLからソースコードを、あなたのプログラムと同じディレクトリにTextIO.javaファイルを作成する必要があります.class "を作成し、作業中のプロジェクトと同じディレクトリに配置します。

以下

は、私たちはあなたが

名前をメモを取るために作成したファイル

のものを使用する場所これは言わせてそれが

/* 
*this is simple way to create a 
* Class which will user input 
* in either int,double,string 
    */ 
package collecting_user; 

/** 
* 
* @author Tejiri 
*/ 
import java.util.Scanner; 
public class TextIO { 
    public int getlnInt(){ 
     int integer; 
     Scanner inputInt = new Scanner(System.in); 
     integer = inputInt.nextInt(); 
     return integer; 
    } 
    public double getDouble(){ 
     double getDouble; 
     Scanner theput = new Scanner(System.in); 
     getDouble = theput.nextDouble(); 
     return getDouble; 
    } 
    public String getString(){//this is used to create your own String method 
     String getString; 
     Scanner theString = new Scanner(System.in); 
     getString = theString.next(); 
     return getString; 
    } 
    public void put(String name){ 
     System.out.println(name); 
    } 
} 

をどのように行われるかの一例です両方のパッケージのうち、私のここでは、プロジェクトと同じユーザ_を収集しています

/* 
* In this progamme i will be showing how to create a class with different method 
* and then calling them from here 
* which are mostly input entered by the user 
*/ 
package collecting_user; 

/** 
* 
* @author Tejiri 
*/ 
public class Collecting_User { 

    /** 
    * @param args the command line arguments 
    */ 
    public static void main(String[] args) { 
     String username; 
     TextIO TextIO = new TextIO(); 
     TextIO.put("enter your name"); 
     username= TextIO.getString(); 
     TextIO.put("Hellow, welcome back Boss " + username); 

     //this will ask the use to enter a Integer only 
     while(true){ 
     try{ 
      TextIO .put("please enter a number only"); 
     String num = TextIO.getString(); 
     double x = Double.parseDouble(num); 
     TextIO.put("the number * 2 is " + x * 2); 
     TextIO.put("thank for entering the number"); 
     break; 
     } 

     catch(NumberFormatException x){ 
      TextIO.put("Please you must enter number only");   
     } 
     } 
    } 
} 

私はこれがあなたの問題を解決することを望みます

関連する問題