when I go to the directory which contains the .java class, which in turn contains the main() method, and run javac Application.java
, I get this error:
And then when I run java Application.java
just to see the output, I get this error:
Error: Could not find or load main class Application.java
Apparently it doesn't even recognize the class there.
This is the output of java -version
:
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
This is the output of javac -version
:
javac 1.8.0_45
Not really sure what's wrong.
Any ideas?
The reason it's not managing to compile your application is that you're importing classes from elsewhere, but you've not told the compiler where to find those classes. You need to add them to the class path for the compiler. In this case, you're importing some classes from the Spring framework, but you haven't supplied the relevant .jar
files to the compiler so that it knows where to find the classes you're importing.
The second error you get is when you try to run your program, but you can't because you haven't managed to generate a compiled version.
I would very strongly recommend that you download Eclipse or IntelliJ IDEA or a similar IDE, and use that for your development and compilation. It will handle pretty much all of this for you. You have a painful road ahead of you if you want to compile from the command line.