2017-01-17 4 views
0

리눅스 서버에 프로그램을로드하는 데 문제가 있습니다. 내가 사용하고있는 IDE에서 내 코드를 복사하여 복사 할 수 있었고 서버가 컴파일되고 실행되도록하고 실행을 비 웠습니다. 나는 println 줄을 printf로 바꿨고 파일이 컴파일되지 않고 매번 "주 클래스 Program01을 찾거나로드 할 수 없습니다"라는 오류 메시지가 나타납니다. 방금 작동했던 예전 코드를 붙여 넣을 때를 포함하여, 노력하고있는 모든 것이 실패하고 있습니다. 제가 고칠 수있는 것에 대한 다른 의견을 찾고 있습니다. "312032486"번호의 입력 파일에서 가져옵니다. 메인 클래스를 찾거나로드 할 수없는 이유가 궁금합니다. 나는 다른 모든 것이 의도 한대로 작동하고 있다고 생각합니다.자바 파일 오류 : 메인 클래스를 찾지 못했습니다.

내가 자바를 처음 사용하는 사람들을 보면서 모든 기기를 열어 줘서 고마워. 코멘트에있는 당신의 발언 후

/* 
* To change this license header, choose License Headers in Project Properties. 
* To change this template file, choose Tools | Templates 
* and open the template in the editor. 
*/ 
package program01; 

import java.util.Scanner; 

/** 
* 
* @author Devin 
*/ 
public class Program01 { 

/** 
* @param args the command line arguments 
*/ 
public static void main(String[] args) { 
    // TODO code application logic here 
    // Create variables for birth rate, death rate and immigration raet 
    int birthRate = 1/7; 
    int deathRate = 1/13; 
    int immigrationRate = 1/45; 

    // Variable creating the number of seconds per year 
    int secondsPerYear = 60 * 60 * 24 * 365; 

    // Variable to find births, deaths and immigrants added per year 
    int birthsPerYear = birthRate * secondsPerYear; 
    int deathsPerYear = deathRate * secondsPerYear; 
    int immigrantsPerYear = immigrationRate * secondsPerYear; 

    // Scanner method to GET population through input.data 
    Scanner sc = new Scanner (System.in); 
    System.out.printf("Enter population: "); 
    int population = sc.nextInt(); 
    System.out.printf("Population is: " + population); 

    // Math to create variables for population per X year 
    double populationYear0 = population; 
    double populationYear1 = populationYear0 + birthsPerYear - deathsPerYear + immigrantsPerYear; 
    double populationYear2 = populationYear1 + birthsPerYear - deathsPerYear + immigrantsPerYear; 
    double populationYear3 = populationYear2 + birthsPerYear - deathsPerYear + immigrantsPerYear; 
    double populationYear4 = populationYear3 + birthsPerYear - deathsPerYear + immigrantsPerYear; 
    double populationYear5 = populationYear4 + birthsPerYear - deathsPerYear + immigrantsPerYear; 

    // Print out the variables data from code above 
    System.out.println("Population Year 0: " + populationYear0); 
    System.out.println("Population Year 1: " + populationYear1); 
    System.out.println("Population Year 2: " + populationYear2); 
    System.out.println("Population Year 3: " + populationYear3); 
    System.out.println("Population Year 4: " + populationYear4); 
    System.out.println("Population Year 5: " + populationYear5); 

} 

} 
+0

실행에 사용중인 명령은 무엇입니까? – Amita

+0

내 학교의 Linux 서버를 사용하여 SubmitJ라는 명령을 사용합니다. 그렇다면 그것은 내가 메인 클래스를 선택 하고이 프로그램을 선택하면 Program01 내게 오류가 발생합니다. 내 다른 2 개의 메인 클래스 프로그램은 잘 작동합니다. – Devin

+0

패키지도 있습니까? 'jar' 또는'class'es로 컴파일합니까? 서버는 온라인 판사를 의미합니까? – xenteros

답변

0

나는 package program01;를 제거하면 충분한 될 것이라고 확신합니다. 클래스가 특정 패키지에 있으면 해당 디렉토리에 파일을 저장해야합니다.

영업 폴더 구조는 다음과 같습니다

/cs116 
    Program01.class 

그래서 패키지 선언이 유효하지 않습니다. 패키지 선언을 제거하면 문제가 해결됩니다.

+0

내 자신의 게시물에 스크린 샷으로 응답했지만 다른 두 클래스/java 파일은 완벽하게 작동하지만 Program01은 작동하지 않습니다. – Devin

+0

'java program01.Program01.class'가 잘못되었으므로 클래스 확장을 지정하지 말아야합니다. – rkosegi

+0

이것은 단지 바보입니다. 클래스를 다른 패키지로 옮겨서 작동 시키십시오. – rkosegi

관련 문제