VannyJ
VannyJ

Reputation: 75

How to run javadoc from Windows 10?

Beginner here. I've just downloaded the Java JDK, the left large button at http://www.oracle.com/technetwork/java/javase/downloads/index.html and installed. Java is running, I've run it from the command line. I'd like to run javadoc without typing its full path name. But even when I do that, probably because there is a space in c:\Program Files\java.... it's not able to be found by Windows. How can I just run javadoc from the command line?

Also, why I have you, why does java run from the command line and javadoc doesn't? They are both in the same directory.

Windows error message at the command line.

javadoc /? 'javadoc' is not recognized as an internal or external command, operable program or batch file.

UPDATE: Geany (which is a light Java editor) can't find javac either. This is probably related to the above problem.

Upvotes: 3

Views: 8542

Answers (2)

cayhorstmann
cayhorstmann

Reputation: 3371

The Java installer adds the directory "c:\Program Files\Common Files\Oracle\Java\javapath" to the PATH environment variable. That directory contains four executables: java.exe, javaw.exe, javac.exe, and jshell.exe. The other tools of the Java Development Kit are in a different directory, such as "c:\Program Files\Java\jdk-17\bin". You can provide the complete path "c:\Program Files\Java\jdk-17\bin\javadoc", or you can add that directory to the PATH environment variable.

Upvotes: 1

KiranGautam
KiranGautam

Reputation: 150

Javadoc Compilation

To generate the html documentation, run Javadoc followed by the list of source files, which the documentation is to be generated for, in the command prompt (i.e. Javadoc [files]). Javadoc also provides additional options which can be entered as switches following the Javadoc command (i.e. Javadoc [options] [files]). Here are some basic Javadoc options:

-author - generated documentation will include a author section
-classpath [path] - specifies path to search for referenced .class files.
-classpathlist [path];[path];...;[path] - specifies a list locations (separated by ";") to search for referenced .class files.
-d [path] - specifies where generated documentation will be saved.
-private - generated documentation will include private fields and methods (only public and protected ones are included by default).
-sourcepath [path] - specifies path to search for .java files to generate documentation form.
-sourcepathlist [path];[path];...;[path] - specifies a list locations (separated by ";") to search for .java files to generate documentation form.
-version - generated documentation will include a version section

To answer your question:

Javadoc [options] [files]
Javadoc java_file_name.java

Make sure you have a system variable created for JAVA_HOME for it to work.

Upvotes: 0

Related Questions