Error: Could not find or load main class solution

1

I'm training for OBI and I'm getting the exercises on your website and sending to run on it too, but my code is giving error:

  

Error: Could not find or load main class solution

" Error: Could not find or load the main class solution " and in my terminal too, why?

package treinamento;

import java.util.Scanner;

/**
*
* @author mrminerin
*/
public class solucao {

public static void main (String[]args) {
    Scanner sc = new Scanner(System.in);

    int n = Integer.parseInt(sc.nextLine());
    String [] pedacos = sc.nextLine().split(" ");
    int [] pedacos2 = new int[pedacos.length];
    int pedaco = 0;
    for (int i = 0; i < pedacos.length; i++) {
        pedacos2[i] = Integer.parseInt(pedacos[i]);    
        pedaco += pedacos2[i];      
    }
    System.out.println(pedaco - n);
  }

}
    
asked by anonymous 26.05.2017 / 04:09

1 answer

3

I ran some tests with your class and I was able to run it.

You should be careful how you run your class, if you try to call it inside the training folder you will not be able to rotate.

 ── treinamento
    ├── solucao.class
    └── solucao.java

You need to call out the folder as java treinamento.solucao .

If you want to run directly inside the training folder, you can remove the package declaration at the beginning of the file, so inside the training folder you will be able to run with java solucao .

Note: Name of classes in java are written from another form

    
26.05.2017 / 05:26