I am following examples from a book but i have an error when i try to save the code in a mods directory. When i type javac -d mods --module-source-path src src\com.jdojo.intro\module-info.java src\com.jdojo.intro\com\jdojo\intro\Welcome.java
I have the error
javac: invalid flag: --module-source-path
Usage: javac <options> <source files>
use -help for a list of possible options
The files are all in the correct directories.
Using java version "9" Java(TM) SE Runtime Environment (build 9+180) Java HotSpot(TM) 64-Bit Server VM (build 9+180, mixed mode)
First check the compiler version being called:
javac -version
probably there is a previous installation being used. In that case adjust the PATH
environment variable so the path to the Java 9 installation is a the very beginning of it. (or just use the full path when calling javac, like in \some\dir\java\jdk9\bin\javac
)
I use the following batch file (windows) to change my environment to Java 9:
@set JAVA_HOME=%JDK9_HOME%
@PATH .;%JAVA_HOME%\bin;%PATH%
@java -version
having set JDK9_HOME
to the directory where I installed java.