Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GoikLectures
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Goik Martin
GoikLectures
Commits
fc9c2188
Commit
fc9c2188
authored
8 years ago
by
Goik Martin
Browse files
Options
Downloads
Patches
Plain Diff
Completing the exercise
parent
d45e8306
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Doc/Sd1/appendix.xml
+64
-4
64 additions, 4 deletions
Doc/Sd1/appendix.xml
with
64 additions
and
4 deletions
Doc/Sd1/appendix.xml
+
64
−
4
View file @
fc9c2188
...
...
@@ -408,15 +408,75 @@ inputSecond.txt</programlisting>
./Sda1/Jdom/Html2Html/src/main/resources/imageExample.html
</programlisting>
<tip>
<para/>
<orderedlist>
<listitem>
<para/>
<para>
Read about reading from files by using instances of
<classname
xlink:href=
"http://www.tutorialspoint.com/java/io/bufferedreader_readline.htm"
>
java.io.BufferedReader
</classname>
.
</para>
</listitem>
<listitem>
<para>
Reading from standard input may be achieved by:
</para>
<programlisting
language=
"java"
>
final BufferedReader source = new BufferedReader(new InputStreamReader(System.in));
...
</programlisting>
</listitem>
<listitem>
<para/>
<para>
You may create an executable jar archive using Maven.
Starting from the
<code>
mi-mavem-archetype-quickstart
</code>
your
<filename>
pom.xml
</filename>
already contains a blueprint. Just
insert your class containing the entry
<methodname>
main(...)
</methodname>
method (i.e.
<classname>
de.hdm_stuttgart.mi.sd1.grep.Grep
</classname>
in the
current example) accordingly:
</para>
<programlisting
language=
"xml"
>
<
plugin
>
<
groupId
>
org.apache.maven.plugins
<
/groupId
>
<
artifactId
>
maven-shade-plugin
<
/artifactId
>
<
version
>
2.4.1
<
/version
>
<
configuration
>
<
transformers
>
<
transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"
>
<
manifestEntries
>
<
Main-Class
>
<emphasis
role=
"bold"
>
de.hdm_stuttgart.mi.sd1.grep.Grep
</emphasis>
<
/Main-Class
>
<
/manifestEntries
>
<
/transformer
>
<
/transformers
>
<
/configuration
>
<
executions
>
<
execution
>
<
phase
>
package
<
/phase
>
<
goals
>
<
goal
>
shade
<
/goal
>
<
/goals
>
<
/execution
>
<
/executions
>
<
/plugin
>
</programlisting>
<para>
Running
<command>
mvn
</command>
<option>
install
</option>
will
create an executable jar file
<filename>
~/.m2/repository/de/hdm-stuttgart/mi/sd1/grep/0.9/grep-0.9.jar
</filename>
with
<quote>
~
</quote>
denoting your home directory. You may then
create a simple shell wrapper script
<filename>
mygrep
</filename>
(don't forget to supply execute permission) hiding the
<command>
java
</command>
execution stuff:
</para>
<programlisting
language=
"none"
>
#!/bin/sh
# A simple wrapper hiding java execution stuff.
# Do not forget to make this file executable by issuing "chmod ugo+x mygrep"
java -jar ~/.m2/repository/de/hdm-stuttgart/mi/sd1/grep/0.9/grep-0.9.jar $*
#end
</programlisting>
<para>
You my now simply invoke your application. The following
example reads from standard input by virtue of a pipe:
</para>
<programlisting
language=
"none"
>
>
cat Testdata/input.txt | ./bin/mygrep red
The red cross acts worldwide
</programlisting>
</listitem>
</orderedlist>
</tip>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment