Skip to content

Commit

Permalink
- Renamed a number of exercises, hence changes to folder names and re…
Browse files Browse the repository at this point in the history
…ferences in the README.md

- Also added the final exercise for JMod
- Corrected an important message about the distributable
  • Loading branch information
neomatrix369 committed Apr 21, 2017
1 parent 1f92998 commit 2411391
Show file tree
Hide file tree
Showing 37 changed files with 102 additions and 90 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ see [http://openjdk.java.net/projects/jigsaw/quick-start](http://openjdk.java.ne
- Missing requires [./session-1-jigsaw-intro/05_Missing_requires](./session-1-jigsaw-intro/05_Missing_requires)
- Missing exports [./session-1-jigsaw-intro/05_Missing_exports](./session-1-jigsaw-intro/05_Missing_exports)
- Services [./session-1-jigsaw-intro/06_Services](./session-1-jigsaw-intro/06_Services)
- javac --patch-module option [./session-1-jigsaw-intro/08_XModules_Overries](session-1-jigsaw-intro/08_patch_module_option)
- Modules export conflict [./session-1-jigsaw-intro/10_ModulesExportConflict](./session-1-jigsaw-intro/10_ModulesExportConflict)
- javac --patch-module option [./session-1-jigsaw-intro/08_XModules_Overries](session-1-jigsaw-intro/07_patch_module_option)
- Modules export conflict [./session-1-jigsaw-intro/10_ModulesExportConflict](session-1-jigsaw-intro/08_ModulesExportConflict)

- Session 2: JLink
- The linker [./session-2-jlink/07_The_linker](session-2-jlink/07_JMod)
- JLink example [./session-2-jlink/09_JLink](./session-2-jlink/09_JLink)
- JLink example [./session-2-jlink/09_JLink](session-2-jlink/01_JLink)
- JMod example [./session-2-jlink/02_JMod](session-2-jlink/02_JMod)

- Session 3: JShell [./session-3-jshell/](./session-3-jshell/)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ normal=$(echo -en "${esc}[m\017")

echo
echo "${info} *** Running 'com.greetings.Main' from the module 'com.greetings' using the java in the 'executable' folder *** ${normal}"
echo "${info} *** The 'executable' folder is a distributable folder and we should be able to run it independent on another machine / platform *** ${normal}"
echo "${info} *** The 'executable' folder is a distributable folder and we should be able to run it independent on another machine but for the same platform *** ${normal}"
echo "${info} *** Using the command-line action 'executable/bin/java --module com.greetings com.greetings.Main' *** ${normal}"
echo "${info} *** Please note that the distributable is platform specific *** ${normal}"
echo
executable/bin/java --module com.greetings com.greetings.Main

Expand Down
25 changes: 25 additions & 0 deletions session-2-jlink/02_JMod/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
### The JMod example

This example shows how to use `jmod`, `jmod` is a tool used to package modules or package jars into a compress file which is still different from a jar format.

It is similar to the `jimage` format but not distributed run-time, its not certain of its application yet.

**Note:** in case one of the below `.sh` script fails due to the `tree` command, please take a look at [Download and install the `tree` and `wget` command](../../README.md) section in the README.md file and apply the appropriate solution.

Modules involved just like in the previous example:
```
com.greetings
org.astro
```

Both the modules are compiled together from the sources into the folder `mods` with the following commands:

$ ./compile.sh

And we run the `JMod` command with the following command:

$ ./runJMod.sh

Check the contents of both these script files (use the `cat` command or a text editor) to see what they are doing and why - interesting instructions and information in there.

See [../01_Greetings/README.md](../01_Greetings/README.md) to learn more about package and module naming conventions and how to avoid confusions between them.
42 changes: 42 additions & 0 deletions session-2-jlink/02_JMod/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

set -eu

# Escape code
esc=$(echo -en "\033")

info="${esc}[0;33m"
normal=$(echo -en "${esc}[m\017")

runTree()
{
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] ; then
cmd //c "tree /f /a $1"
else
tree -fl $1
fi
}

COM_GREETINGS_FOLDER="mods/com.greetings"
ORG_ASTRO_FOLDER="mods/org.astro"

echo ""
echo "${info} *** Compiling modules in $ORG_ASTRO_FOLDER *** ${normal}"
javac -d $ORG_ASTRO_FOLDER \
src/org.astro/module-info.java \
src/org.astro/org/astro/World.java

echo ""
echo "${info} *** Displaying the contents (modules) of the '$ORG_ASTRO_FOLDER' folder *** ${normal}"
runTree "$ORG_ASTRO_FOLDER"

echo ""
echo "${info} *** Compiling modules in $COM_GREETINGS_FOLDER *** ${normal}"
javac --module-path mods \
-d $COM_GREETINGS_FOLDER \
src/com.greetings/module-info.java \
src/com.greetings/com/greetings/Main.java

echo ""
echo "${info} *** Displaying the contents (modules) of the '$COM_GREETINGS_FOLDER' folder *** ${normal}"
runTree "$COM_GREETINGS_FOLDER"
29 changes: 29 additions & 0 deletions session-2-jlink/02_JMod/runJMod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

set -eu


# Escape code
esc=$(echo -en "\033")

info="${esc}[0;33m"
normal=$(echo -en "${esc}[m\017")

echo ""
echo "${info} *** Removing any existing greetings.jmod *** ${normal}"
rm -f greetings.jmod

echo
echo ""
echo "${info} *** Creating a module (greetings.jmod) from multiple modules / packages / classes with jlink. *** ${normal}"
jmod create \
--class-path mods/com.greetings:mods/org.astro \
greetings.jmod

echo ""
echo "${info} *** Enlisting the contents of the module (greetings.jmod) *** ${normal}"
jmod list greetings.jmod


echo "${info} *** Currently JMOD files can be used at compile time and link time, but not at run time. *** ${normal}"
echo "${info} *** Read further about JMod files at http://openjdk.java.net/jeps/261#Packaging:-JMOD-files *** ${normal}"
29 changes: 0 additions & 29 deletions session-2-jlink/07_The_linker/compile.sh

This file was deleted.

14 changes: 0 additions & 14 deletions session-2-jlink/07_The_linker/linkModules.sh

This file was deleted.

33 changes: 0 additions & 33 deletions session-2-jlink/07_The_linker/packing.sh

This file was deleted.

9 changes: 0 additions & 9 deletions session-2-jlink/07_The_linker/run.sh

This file was deleted.

0 comments on commit 2411391

Please sign in to comment.