2017-12-04 4 views
-2

자바 프로그램을 실행,하지만 내 교수 확인하는 것입니다 방법 명령
"java Caesar input.txt output.txt"오류 나는 완전한 자바 프로그램이

를 사용하여 CMD를 통해 프로그램이 제대로 작동하는 것을 확인하면서

하지만 내가 겪고있는 문제는 "javac Caesar.java"을 사용하여 컴파일하면 Caesar.class 파일이 폴더에 생성되지만 "java caesar input.txt output.txt"으로 실행하면 오류 : Could not find or load main class caesar이 발생합니다.

내가 뭘 잘못하고 있니?
필요에 따라 추가 정보를 제공 할 수 있습니다. 모든 javac Caesar.java

package caaesar; 

import java.io.File; 
import java.io.IOException; 
import java.io.FileNotFoundException; 
import java.io.BufferedWriter; 
import java.io.FileWriter; 
import java.util.Scanner; 

/** 
* 
* @author Connorbboggs 
* Version 12.03.2017 
*/ 
public class Caaesar 
{ 

private static Scanner sc; 
private static FileWriter fw; 
private static BufferedWriter bw; 
private Scanner inp; 
private Scanner outp; 
//DecodeChar class provided by you 
public static char decodeChar(int n, char ch) 
{ 
    int ord; 
    if (ch >= 'A' && ch <= 'Z') 
    { 
     ord = ch - 'A'; 
     ord += n; 
     ord %= 26; 
     return (char)(ord + 'A'); 
    } 
    else if (ch >= 'a' && ch <= 'z') 
    { 
     ord = ch - 'a'; 
     ord += n; 
     ord %= 26; 
     return (char)(ord + 'a'); 
    } 
    else 
    { 
     return ch; 
    } 
} 

public static void main(String[] args) 
{ 
    //File input for decode.txt with the encrypted text 
    File inputFile = new File(args[0]); 
    //Output for the decrypted text 
    File outputFile = new File(args[1]); 
    try 
    { 
     //input from inputFile 
     sc = new Scanner(inputFile); 
     int shift = sc.nextInt(); 
     String decoded = ""; 
     //while lines are available text is fed to inputFile 
     while(sc.hasNextLine()) 
     { 
      //Lines being fed into string line 
      String line = sc.nextLine(); 
      //for loop to feed into decoded using decodeChar 
      for(int i=0; i<line.length(); i++) 
      { 
       decoded += decodeChar(shift, line.charAt(i));      
      } 
      decoded += '\n'; 
     } 
     //Just to verify that the text is decrypted 
     System.out.println(decoded); 
     try 
     { 
      //create a fileWriter for outputFile 
      fw = new FileWriter(outputFile); 
      //write "decoded" to the file 
      fw.write(decoded); 
      //close the file 
      fw.close(); 
     } 
     //exception catching 
     catch (IOException ex) 
     { 
      ex.printStackTrace(); 
     } 
    } 
    //more exception 
    catch (FileNotFoundException e) 
    { 
     e.printStackTrace(); 
    } 
} 

} 
+3

자본 C는 소문자 c와 다릅니다. 둘 다 시도 했니? –

+0

모든 Java 식별자는 대소 문자를 구분합니다. '카이사르'와'카이사르'는 같은 식별자가 아닙니다. – Andreas

+0

맞아, 미안하지만 오타 였고 대문자와 소문자를 모두 사용하면 같은 오류가 발생합니다. 다음은 정확하게 진행되는 화면입니다 : https://gyazo.com/a39a5793fced9fc67b22abb22317957c – Ronave4C

답변

0

먼저

귀하의 Caaesar 클래스는 caaesar 패키지의 일부입니다 ... 파일을 찾을 수없는 말을한다.

완전한 클래스 이름은 교수

java Caesar input.txt output.txt 

다음 당신은 다음의 모든 필요를 실행하고자하는 경우이 클래스를

0

를 실행하는 방법 인 caaesar.Caaesar이다. 철자가 중요하며 대문자인지 소문자 인지도 중요합니다. Caesar 호출해야합니다 코드 파일에있는 당신의 코드 파일이 Caesar.java을 호출해야

  • ,
  • 클래스를
  • public static void main(String[]로 시작하는 방법을 포함해야합니다 코드 파일의 클래스입니다.
  • 파일 맨 위에 패키지 선언이 있어야합니다.

이러한 모든 조건을 충족시키고 세부 사항에 대해 신중을 기하십시오.

관련 문제