0

Running on Linux, with IntelliJ IDE project, with Java 8.

Java -version gives me

openjdk version "1.8.0_91" OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~16.04.1-b14) OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)

If I cd to the folder in which my fooBar.Java is, ideaprojects/fooBar/src/com/company, and run java fooBar the output is: Error: Could not find or load main class fooBar

Should I copy the .class in there? Or what am I doing wrong?

cbll
  • 6,499
  • 26
  • 74
  • 117
  • You need to respect the package in which the class is. If the main class is in `ideaprojects/fooBar/src/com/company`, you need to start `java` from `ideaprojects/fooBar` and pass the main class as `com.company.FooBar`. – Tunaki Oct 10 '16 at 10:01
  • @Tunaki running `java com.company.fooBar` from the ideaprojects/fooBar folder provides the sam error. – cbll Oct 10 '16 at 10:12
  • That was a guess. Please refer to the linked question for all the possible explanations. – Tunaki Oct 10 '16 at 10:13
  • I've tried most of them by now, no luck unfortunately. I don't quite get it.. – cbll Oct 10 '16 at 10:14
  • Solved - i had to cd to the /src/ folder instead – cbll Oct 10 '16 at 10:20

0 Answers0