Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c5ce676

Browse files
committed
Add Java language instructions to the README.
1 parent ed8b0be commit c5ce676

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

‎README.markdown‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ A compendium for self-education about "data structures and algorithms," created
66
1. [How to use this repository](#how-to-use-this-repository)
77
1. [Running the code](#running-the-code)
88
* [JavaScript](#javascript)
9+
* [Java](#java)
910
* [PHP](#php)
1011
* [Perl](#perl)
1112
* [Python](#python)
@@ -68,6 +69,42 @@ Alternatively, open the `.html` file in your web browser (probably just by doubl
6869
* [Set a breakpoint - Firefox Developer Tools](https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Set_a_breakpoint)
6970
* [Step through code - Firefox Developer Tools](https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Set_a_breakpoint)
7071

72+
#### [Java](https://java.com/)
73+
74+
The Java code samples are all compatible with [Java SE](https://en.wikipedia.org/wiki/Java_Platform%2C_Standard_Edition "Java Platform, Standard Edition") 8. They must first be compiled before they can be run. To compile them, invoke the Java compiler like this at a command shell:
75+
76+
```sh
77+
# to compile the recursive implementation of the binary search example
78+
javac binary_search/BinarySearchRecursive.java
79+
```
80+
81+
Once compiled, the code samples can be run by informing the Java application launcher where to find them, and which class's code to execute. Do so like this:
82+
83+
```sh
84+
java -classpath binary_search BinarySearchRecursive
85+
# ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
86+
# Tell Java to look for Name of the class whose `main()`
87+
# compiled code (`.class`) method should be executed.
88+
# files in the
89+
# following directory.
90+
```
91+
92+
Java's standard debugger is called `jdb` (on both [macOS/*nix](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jdb.html) and [Windows](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/jdb.html)). To debug the Java code samples, first compile them with the `-g` option to include debugging information:
93+
94+
```sh
95+
javac -g binary_search/BinarySearchRecursive.java
96+
# ^^
97+
# Make sure you include this `-g` switch!
98+
```
99+
100+
Once compiled with debugging information included, you can use the Java debugger to inspect the values of all variables during program exeuction, run the code one line at a time, step by step, and more:
101+
102+
```sh
103+
jdb -classpath binary_search BinarySearchRecursive.java
104+
```
105+
106+
Once in the debugger, type `help` to get help. (The `jdb` help is pretty thorough but can be terse, so feel free to hop into the [Better Angels's public chat room](https://gitter.im/betterangels/better-angels) if you need help from a human.)
107+
71108
#### [PHP](https://php.net/)
72109

73110
The PHP code samples are all compatible with PHP 5.6 and newer. To run them, execute them like this at a command shell:
@@ -141,6 +178,7 @@ You can use the debugger to run one line of code at a time, and it will allow yo
141178
In addition to containing detailed inline code comments, each example is also formally documented using the best practices of the language in which the example code is written. Formal documentation means that the files, classes, class members, methods, functions, arguments of each function, and other relevant implementation details are accessible by tools that automatically generate a programmer's manual for how to use the class, method, or function implemented by the example. Each language has its own de-facto standard tool for this:
142179

143180
* [JSDoc](http://usejsdoc.org/) is used for documenting the JavaScript code samples.
181+
* [Javadoc](https://docs.oracle.com/javase/8/docs/technotes/guides/javadoc/index.html) is used for documenting the Java code samples.
144182
* [PHPDoc](https://phpdoc.org/) is used for documenting the PHP code samples.
145183
* [Plain Old Documentation (POD)](http://perldoc.perl.org/perlpod.html) format is used for documenting the Perl code samples.
146184
* [Google-style Python docstrings](https://google.github.io/styleguide/pyguide.html?showone=Comments#Comments) are used for documenting the Python code samples. Additionally, the Python code samples embed [`doctest`s](https://en.wikipedia.org/wiki/Doctest) to show example usage and output.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /