0

I installed java on my MacBook, I'm trying to start a simple hand that is in a jar but I just can't.

The command I launch is the following:

java -cp sell.jar it.test.testina

The error is always this:

error: Cannot Find or Load the Main Class it.test.testina Launching the same command on Windows everything works correctly

java version "1.8.0.351".

I guess the problem is that I am not setting the classpath.

Thank you in advance for the helps.

I tried to set java_home in bash_profile but it does not work.

Below is my code in my class:

import java.text.DecimalFormat;
public class testina {
    public static void main(String[] args) {
        DecimalFormat decimalFormat = new DecimalFormat("#,00");
        double dprice= Double.parseDouble( decimalFormat.format(4.551d));
        System.out.println(dprice);
    }
}

In this link I can see output of the command jar tf sell.jar

Hi computer
  • 946
  • 4
  • 8
  • 19
  • Please post the source up to the declaration of your main class. Note class names begin [upper case](https://technojeeves.com/index.php/aliasjava1/106-java-style-conventions) – g00se Jan 16 '23 at 16:46
  • I try with lowercase and uppercase, the same problem – Leone Miceli Jan 16 '23 at 16:57
  • 2
    Please post output of the following *formatted as code* into your question: `jar tf sell.jar` – g00se Jan 16 '23 at 17:36
  • I modify the question and add a link containd the exrtact of command jar tf sell.jar – Leone Miceli Jan 17 '23 at 08:56
  • https://wetransfer.com/downloads/9c95b3f7b72182b609403d48e99ac6c020230117090034/ee35a0 – Leone Miceli Jan 17 '23 at 09:04
  • I don't see the file `it/test/testina.class` in your jar. It's likely that you have built the jar incorrectly. – k314159 Jan 17 '23 at 09:12
  • 1
    Yes, that class is absent. *Is* it your main class anyway? Why is it in a package called 'test'? It would be a good idea to paste pom.xml *formatted as code in the question* – g00se Jan 17 '23 at 11:09

0 Answers0