Answer the question
In order to leave comments, you need to log in
How to compile and run Java from terminal if it gives this error?
1) There are directories:
- - - - application:
- - out - for binaries
- - src - for sources (App.java file is here)
Being in the application directory, I want to compile files from src to out:
javac -sourcepath ./src -d ./out App.java
Error
:
error: file not found: App.java
Usage: javac
use --help for a list of possible options
out App.java
then everything will work and the binary will be in out.
2) If go to out directory and try to run App.class with:
java App
or
java -classpath ./App
Error:Could not find or load main class App
(PS code contains nested class)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question