Hello world/Newbie: Difference between revisions

Java: add installation instructions, explanation of how to get started and what the keywords in the example mean and where to go for further reading.
(→‎{{header|Agda}}: added Agda)
(Java: add installation instructions, explanation of how to get started and what the keywords in the example mean and where to go for further reading.)
Line 960:
 
=={{header|Java}}==
Many people already have the Java SE runtime installed on their computer for use by various existing programs, but to develop Java programs, a JDK (Java Development Kit) must be installed too. A JDK consists of a few components: A JRE (Java Runtime Environment), which includes a JVM (Java Virtual Machine) and the JCL (Java Class Library) for running Java applications, and a Java compiler, which turns human-readable Java source code into byte code that is then executed by the virtual machine.
{{incomplete|Java|No installation instructions}}
 
1. Various JDK implementations exist, the majority of which (including the reference implementation, OpenJDK) are free and open-source, and available for almost all popular operating systems and CPU architectures. Following are links to the latest (until 2023) official OpenJDK LTS binary release (version 17):
* [https://www.oracle.com/java/technologies/downloads/ Oracle's commercially licensed OpenJDK release.]
* [https://jdk.java.net/17/ Oracle's GPL licensed OpenJDK release.] (This release has no installer)
* Alternate OpenJDK sources/releases:
* [https://docs.microsoft.com/en-us/java/openjdk/download Microsoft's GPL licensed OpenJDK release.] (Provides installer)
* [https://developer.ibm.com/languages/java/semeru-runtimes/downloads?license=GPL IBM's GPL licensed OpenJ9-based OpenJDK release.] IBM's JDK releases (currently LTS versions 8 and 11) use the OpenJDK class libraries, but swap out Oracle's HotSpot JVM for Eclipse's OpenJ9 JVM, which claims to offer certain benefits for specific use cases, like in container/cloud environments. (Provides installer)
* Many Linux and UNIX variants have OpenJDK releases available in their package repositories.
 
 
2. Java programs are often developed with one of various full-featured IDEs, but this is not a requirement. For simplicity, we will stick with using only pre-installed text editors. After the installation has completed, open a terminal window (Command prompt on Windows) and try running the command: <lang shell>javac -version</lang> If you see an output similar to <code>javac <version_number></code>, the JDK was successfully installed. You are now prepared to develop and run Java applications.
 
 
3. Using a plain-text editor (vim, nano, emacs on UNIX-like operating systems, or notepad on Windows), re-type or copy and paste one of the following classes into the editor and save it as a file named <code>HelloWorld.java</code>. The file naming step is a very important, as a Java source code file ''must'' be named the same as it's (one and only) public class.
 
<lang Java>
public class HelloWorld {
Line 986 ⟶ 1,001:
</lang>
'''Output: Hello world!'''
 
4. The first class above is the minimum amount of code required to create the traditional "Hello world!" program in Java, it consists of:
* A class definition using the language keywords '''public''' and '''class''', which indicate that this class (a container of both state and functionality) is meant to be externally accessible by other packages (not important in this specific case).
* A method definition named <code>main</code> using the language keywords '''public''', '''static''' and '''void'''. These three keywords, respectively, indicate that: this method is externally invokable (in this case, by the JVM itself), this method can invoked without having to create an instance of the class (known as a class method in other languages), this method does not return any value to it's caller. The identifier name <code>main</code> is not a keyword, but is what the JVM expects to find when a normal Java application is executed. Additionally, the variable <code>args</code> holds any CLI arguments that were provided when the program was ran, it is optional.
* Finally, the predefined method <code>println</code> of the <code>System</code> class's <code>out</code> field is invoked with the string literal "Hello world!", displaying it on the connected terminal's standard out stream.
 
 
5. From here, if you are interested in continuing to learn Java, many in-depth tutorials are available on for free, just a few of them are [https://docs.oracle.com/javase/tutorial/ Oracle's official tutorials], [https://en.wikibooks.org/wiki/Java_Programming Wikibook's Java programming book] and [https://www.w3schools.com/java/default.asp W3School's Java tutorial]. One of Java's main attractions is it's massive library of pre-defined classes, meant to assist in a wide variety of different programming tasks. The reference documentation for these classes and the modules and packages that encompass them can be found on Oracle's official site [https://docs.oracle.com/en/java/javase/index.html here], by choosing A JDK version and then selecting "API Documentation" under the "Specifications" category.
 
=={{header|JavaScript}}==