У меня возникли проблемы с загрузкой моей программы на сервер linux. Мне удалось скопировать мой код из моей IDE, которую я использую, и скомпилировать сервер и запустить код, причем выполнение пустым. Я изменил строки println на printf, и файл не будет компилироваться и дает мне ошибку: «Невозможно найти или загрузить основной класс Program01» каждый раз. В том числе, когда я вставляю свой старый код, который только что работал, все, что я пытаюсь, терпит неудачу. Ищете другие мнения о том, что я могу исправить. Он извлекает из входного файла число «312032486». Просто интересно, почему он не может найти или загрузить основной класс. Я считаю, что все остальное работает по назначению.Файл Java Ошибка: не удалось найти или загрузить основной класс
Спасибо всем, кто взглянет и откроется для любого устройства, поскольку я новичок в java.
/*
* 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);
}
}
Какова команда, которую вы используете для выполнения? – Amita
Использование Linux-сервера из моей школы с помощью команды SubmitJ. Затем он выбирает основной класс, и когда я выбираю эту программу, Program01 это дает мне ошибку. Мои другие 2 основные программы работают очень хорошо. – Devin
У них также есть пакеты? Скомпилируете ли вы 'jar' или' class'es? На сервере, вы имеете в виду онлайн-судьи? – xenteros