-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrdinaryJAR_calls_ModularJAR.sh
executable file
·47 lines (34 loc) · 1.51 KB
/
OrdinaryJAR_calls_ModularJAR.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#/bin/bash
CLASSES=classes
LIBRARY=libs
MODULES=mods
MODULAR=mlibs
rm -rf $CLASSES $LIBRARY $MODULES $MODULAR
# Make modular JAR "org.astro.jar"
$JAVA_9_HOME/bin/javac --module-source-path java9/src -d $MODULES -m org.astro
mkdir $MODULAR
$JAVA_9_HOME/bin/jar --create --file $MODULAR/org.astro.jar -C $MODULES/org.astro .
# Make odrinary JAR "com.greetings"
mkdir $CLASSES
$JAVA_8_HOME/bin/javac -cp java8/src -d $CLASSES java8/src/com/greetings/Main.java
## Remove depended classes(org.astro.jar)
rm -rf $CLASSES/org
mkdir $LIBRARY
$JAVA_8_HOME/bin/jar cvf $LIBRARY/com.greetings.jar -C $CLASSES/ . 1>/dev/null
echo "Check JARs"
echo "* $(ls $MODULAR/*jar)"
$JAVA_9_HOME/bin/jar -d --file $MODULAR/*jar
echo "* $(ls $LIBRARY/*jar)"
$JAVA_9_HOME/bin/jar -d --file $LIBRARY/*jar
echo "--------------------------------------"
echo "Try automatic module calls explicit module"
$JAVA_9_HOME/bin/java -p $LIBRARY:$MODULAR -m com.greetings/com.greetings.Main
echo "--------------------------------------"
echo "Try automatic module calls explicit module with using --add-modules"
$JAVA_9_HOME/bin/java -p $LIBRARY:$MODULAR --add-modules org.astro -m com.greetings/com.greetings.Main
echo "--------------------------------------"
echo "Try unnamed Module calls explicit module by module-path"
$JAVA_9_HOME/bin/java -cp $LIBRARY/* -p $MODULAR com.greetings.Main
echo "--------------------------------------"
echo "Try unnamed Module calls explicit module by class-path"
$JAVA_9_HOME/bin/java -cp $LIBRARY/*:$MODULAR/* com.greetings.Main