• Getting started
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
  • Getting started
    • ➟ Lecture related resources
layered SVG image
layered SVG image
layered SVG image
Primary
Secondary
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
http://codingbat.com

No registration required.

https://www.programmr.com/zone/java
  • Hunt for Challenges within page.

  • Registration required.

https://www.codewars.com
codeabbey.com

Problem list.

rosettacode.org

Programming tasks (including solutions for multiple languages).

reddit.com

Daily Programmer.

Project Euler

Registration required for keeping track of your exercises' status. The following exercises in particular are considered to be useful with respect to this lecture:

1, 2, 4, 5, 8, 9, 11.

Java Programming Tutorial

Basic and more difficult exercises

Java Programming Exercises

Start from the easier exercises.

Java Visualizer

http://prog.mi.hdm-stuttgart.de/java_visualize

Live lecture
      additions
 
      (See installation
      details)
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
  • Getting started
    • ➟ Using the exercises
Using the exercises
  • Getting started
    • ➟ Common software development related resources

Either of:

  • External MI E-examination system access requires VPN:

    • Past years' E-examinations.

    • Your personal exam results.

  • OpenVPN wiki installation page (Login required).

  • HdM_MI_stud.ovpn allows for using a maximum of MI services.

E-examination resources
  • Accessing your computer pool home directory.

  • Windows share \\mi-ad1.srv.mi.hdm-stuttgart.de\xy123 or \\192.168.111.15\xy123.

  • Requires Mi VPN.

  • Getting started
    • ➟ Coached exercises
  • Tuesday and Wednesday 17:45-19:15.

  • Alternating seminar and software exercises: E.g. seminar on Tuesdays, exercises on Wednesdays.

  • Seminar groups of ~12 participants assigned to a tutor.

  • Precondition: You must pass the examination based on its own score excluding bonus points.

  • Examination: 90 points resulting in 1,0, 45 points resulting in 4.0.

  • 0-10 bonus points on top of examination score in case of reaching at least 45 examination points.

  • Examples:

    • 40 examination points: Failed regardless of any number of bonus points

    • 45 Examination points, 10 bonus points. Result: 55 points resulting in a 3.0 mark rather than 4.0.

  • Join exactly one group at the MI E-learning system.

  • Bonus point requirements:

    1. 80% participation rate of all weekly appointments

    2. Presenting at least three exercise solutions of https://freedocs.mi.hdm-stuttgart.de/webhelp/apb.html.

      • Give a brief account on the exercise in question.

      • Explain your solution's concept and present your code.

      • Explain possible problems / pitfalls.

      • Ask your tutor for exercises to avoid thematic clashes

  • Getting started
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
Editing  files
// Filename HelloWorld.java 

public class HelloWorld  {

  public static void main(String[] args)  {
    System.out.println("Hello, world"); 
  }

}
Compiling  file
~/tmp$ ls -al HelloWorld.class 
ls: cannot access 'HelloWorld.class': No such file or directory

~/tmp$ javac HelloWorld.java 

~/tmp$ ls -al HelloWorld.class 
-rw-r--r-- 1 goik fb1prof 419 Sep 23 15:44 HelloWorld.class
Êþº¾^@^@^@6^@^]
^@^F^@^O        ^@^P^@^Q^H^@^R
^@^S^@^T^G^@^U^G^@^V^A^@^F<init>^A^@^C()V^A^@^DCode^A^@^OLineNumberTable^A^@^Dmain^A^@^V(\
  [Ljava/lang/String;)V^A^@
SourceFile^A^@^OHelloWorld.java^L^@^G^@^H^G^@^W^L^@^X^@^Y^A^@^LHello, world^G^@^Z^L^@^[^@\
  ^\^A^@
HelloWorld^A^@^Pjava/lang/Object^A^@^Pjava/lang/System^A^@^Cout^A^@^ULjava/io/PrintStream;\
  ^A^@^Sjava/io/PrintStream^A^@^Gprintln^A^@^U(Ljava/lang/String;)V^@!^@^E^@^F^@^@^@^@^@^\
  B^@^A^@^G^@^H^@^A^@    ^@^@^@^]^@^A^@^A^@^@^@^E*·^@^A±^@^@^@^A^@
^@^@^@^F^@^A^@^@^@^B^@  ^@^K^@^L^@^A^@  ^@^@^@%^@^B^@^A^@^@^@   ²^@^B^R^C¶^@^D±^@^@^@^A^@
^@^@^@
^@^B^@^@^@^D^@^H^@^E^@^A^@^M^@^@^@^B^@^N
HelloWorld.java HelloWorld.class
  • Human readable (kind of 😆).

  • High abstraction level.

  • Text file

  • Machine readable instructions.

  • Non-editable (usually).

  • Binary file.

Executing byte code file
      HelloWorld.class
> java HelloWorld 
Hello, world

Remark: This executes HelloWorld.class rather than HelloWorld.java.

  1. Extending class HelloWorld
  2. Renaming a class file
  3. Editing and compilation
  4. Editing bytecode
  5. Working with variables
  6. Code equivalence
  7. Different byte code, same execution results
  8. A conditional
  9. A loop
HdM license server

Troubleshooting: Insert address manually:

http://jetbrains.mi.hdm-stuttgart.de:11111

External usage requires VPN !

  • Automated builds and testing.

  • Third party libraries e.g. logging.

  • Operating system agnostic:

    Linux, Windows, Mac-OS,...

  • Blueprints for projects.

  • Based on the pom.xml file:

    Project Object Model

  • Easy initial project creation.

  • CLI and IDE support.

  • Extensibility based on archetype catalogs.

mvn --batch-mode -e archetype:generate -DgroupId=de.hdm_stuttgart.mi.sd1 \
-DartifactId=second -Dversion=0.9 -DarchetypeGroupId=de.hdm_stuttgart.mi \
-DarchetypeArtifactId=mi-maven-archetype-helloworld -DarchetypeVersion=1.3

[INFO] Scanning for projects...
      ...
[INFO] BUILD SUCCESS ...

Defining archetype and project details:

mvn --batch-mode  -e archetype:generate  \
                                              \
 -DarchetypeGroupId=de.hdm_stuttgart.mi \ 
 -DarchetypeArtifactId=mi-maven-archetype-helloworld \
 -DarchetypeVersion=1.3 \
                        \
 -DgroupId=de.hdm_stuttgart.mi.sd1  \
 -DartifactId=first  \
 -Dversion=0.9
> cd first        # Enter project directory
> find . -type f  # Search recursively for files
./.gitignore 
./src/main/java/de/hdm_stuttgart/mi/sd1/App.java 
./pom.xml 
> mvn compile
[INFO] Scanning for projects...
       ...
[INFO] Building first 0.9
   ...
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /ma/goik/first/target/classes
[INFO] --------------------------------------------------------
[INFO] BUILD SUCCESS
> find . -type f
...
./target/classes/de/hdm_stuttgart/mi/sd1/App.class
> cd target/classes 
> java de.hdm_stuttgart.mi.sd1.App 
Hello World! 

Change to base directory containing compiled Java classes.

Application execution. Note:

Our App class is being prefixed by the package name de.hdm_stuttgart.mi.sd1 defined by the groupId parameter in Figure 44, “CLI archetype details”.

The expected output result.

Note

Executing this particular class requires a configuration in our project's pom.xml file:

...
<archive>
  <manifest>
    <mainClass>de.hdm_stuttgart.mi.sd1.test.ShowReachedPoints</mainClass>
  </manifest>
</archive> ...
> mvn package
...
 T E S T S
...
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
   ...
[INFO] Building jar: /ma/goik/first/target/first-0.9.jar
...
[INFO] Replacing /ma/goik/first/target/first-0.9.jar with 
         /ma/goik/first/target/first-0.9-shaded.jar
...
[INFO] BUILD SUCCESS
java -jar target/first-0.9.jar
Hello World!

Remark: This will execute HelloWorld.class being contained in first-0.9.jar.

Details on execution
> mvn javadoc:javadoc
[INFO] Scanning for projects...
...
Generating /ma/goik/First/target/site/apidocs/allclasses-noframe.html...
Generating /ma/goik/First/target/site/apidocs/index.html...
Generating /ma/goik/First/target/site/apidocs/overview-summary.html...
Generating /ma/goik/First/target/site/apidocs/help-doc.html...

See e.g. class String documentation.

> mvn clean
...
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ first ---
[INFO] Deleting /ma/goik/first/target
[INFO] ------------------------------------------------------------------------
[
  archetype catalog plugin
 MI archetype repository
        configuration
New MI archetype project
Selecting an archetype
Providing project identifier
Your project's root
pom.xml content change policy
  • Your Maven project depends on its pom.xml file.

  • Enable Auto-import allows for automated re-reading of pom.xml content changes.

layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
  • Getting started
    • ➟ Examination hints.
      • ➟ Starting an exam
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
  • Getting started
    • ➟ Examination hints.
      • ➟ Implementing the project skeleton
  • HTML is difficult to read:

       *     <td><code>a = -3</code>, <code>b = 4</code>, <code>c = 3</code></td>
       *     <td>4 - (-3) = 7</td>
       *   </tr>
       * </table>
       ...
       */
      static public int getMaxAbsoluteDiff(int a, int b, int c) {
        return 42;  // TODO: Implement me correctly
  • ⇒ Generate Javadoc by CLI or Idea.

layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
  • Getting started
    • ➟ Examination hints.
      • ➟ Finish the exam
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image
layered SVG image