-1

I'm trying to execute a simple java code.

the code worked fine using comand line : javac Go.java and java Go, but in Spring Tool Suite 3, the code did not work and I got the error below.

Note that I'm using jdk1.8.0_211

package com.test;

public class Go {

public static void main(String[] args) {
    System.out.println("test");
  }

}

I expect print test, but I get this error :

Error: Can not find or load the main class.
Noureddine
  • 103
  • 1
  • 4
  • 16
  • It's "java com.test.Go", because that's the name of the class (including the namespace) – Progman May 01 '19 at 21:46
  • 1. Use a fully qualified class name. 2. Add a classpath argument when launching your compiled class. – Lesiak May 01 '19 at 21:47
  • With `package com.test;`, your source file should be `XX/com/test/Go.java` (Linux) or ``XX\com\test\Go.java`` (Windows), and you should be in the `XX` directory when you run both `javac com/test/Go.java` and `java com.test.Go` – Andreas May 01 '19 at 22:08
  • I notice that you talk in command line, my code worked using command line in windows, but dosn't work in eclipse, I get the error in descripton. – Noureddine May 01 '19 at 22:37
  • @Progman, I installed a virtual machine windows 10, and I set up the same configuration and the same code, it works, the problem is why this same configuration and code deos not work in my pysical machine – Noureddine May 01 '19 at 22:39
  • @Progman , I added more detail in the description of problem, I'm not the owner of the Laptop, it is managed by the administrator of the company where I work. I noticed that when I change the version of JAVA, the code runs correctly, but after restarting the Laptop, I get the same error again, so the cause of the problem was that the laptop updates java every restart, I fixed my PC to not updates java version again and it works – Noureddine May 28 '19 at 12:50
  • @Progman, I can not write an answer because I don't have the answer button in my web page, can you help by removing that this question is a duplicate problem ? – Noureddine May 28 '19 at 12:55
  • @Andreas I can not write an answer because I don't have the answer button in my web page, can you help by removing that this question is a duplicate problem ? – Noureddine May 28 '19 at 12:56

1 Answers1

0

the cause of the problem is that I'm not the owner of the Laptop, it is managed by the administrator of the company where I work. I noticed that when I change the version of JAVA, the code runs correctly, but after restarting the Laptop, I get the same error again, so the cause was that every restart of the laptop, it updates java version, I fixed my PC to not updating java version again and it works

Noureddine
  • 103
  • 1
  • 4
  • 16