INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and...

46
INFO0062 - Object-Oriented Programming Java basics and guidelines Jean-François Grailet University of Liège Faculty of Applied Sciences Academic Year 2017 - 2018

Transcript of INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and...

Page 1: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

INFO0062 - Object-Oriented ProgrammingJava basics and guidelines

Jean-François Grailet

University of Liège

Faculty of Applied Sciences

Academic Year 2017 - 2018

Page 2: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Contact

Jean-François Grailet

Office: 1.14a, Montefiore Institute

Website: http://www.run.montefiore.ulg.ac.be/~grailet/

• Available in both French and English

• Hover1 Teaching menu then select INFO0062 to get the page for this course

• Updated after each session

• Slides, (suggested) solutions and project details

E-mail: [email protected]

1FR: survoler

Page 3: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java

Page 4: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Compilation and execution of a Java program

.java

Compiler Execution

.class

Virtual machine

javac is the compiler which transforms the Java code into bytecode.

Usage (command line):

$ javac Main.java ClassA.java ClassB.java

java is the command used to execute Java bytecode.

Usage (command line):

$ java Main

1 / 36

Page 5: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Compilation and execution of a Java program (II)

.java

Compiler Execution

.class

Virtual machine

The bytecode is located in .class files, produced by javac.

• For each .java, there will be a .class (Main.java⇒ Main.class)

• Each time you edit a .java, re-compile its .class equivalent for execution.

java requires the class name of the class containing the main() method.

Alternative approach to compile several files with javac:

$ javac *.java

*.java means "all files in the current directory ending in .java".

2 / 36

Page 6: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Terminology

Java Virtual Machine (JVM): virtual machine able to interpret (and/or compile)bytecode in order to execute it on a specific physical machine.

Java Runtime Environment (JRE): complete environment needed to executeJava programs compiled into bytecode. It is composed of the JVM, some classesimplementing the API (Application Programming Interface) and additional librariesand tools.

Java Development Kit (JDK): environment needed to develop Java programs.It is composed of a special JRE (with additional features for developers), tools(such as a compiler, a debugger, etc.), and other stuff (such as monitoring utilities,documentation, etc.).

3 / 36

Page 7: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java and INFO0062

Page 8: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

No problem, only solutions

There are several solutions to start practicing Java.

Picking one might depend on your preferred OS (Operating System).

• I.e., whether you are using Windows, macOS (Mac OS X) or a Linux distribution.

Do not wait to pick and test a solution after this session.

• If you do this a few days before the project deadline, you’re going to have a bad time.

• The sooner your start practicing, the better.

4 / 36

Page 9: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Network 8 as a reference environment

We only ask you one thing: to use Network 8 computers as a reference.

• I.e., your code should compile and run without errors/warnings/crashes.

• This is especially important for the project.

This allows you to ensure your future project will work fine when tested.

• This will also help you to fix warnings that might not appear at your side.

• Or check if you can use a recent Java feature/library.

Network 8 is also your most straightforward solution to code in Java.

• Can be used just like B37 computers (any time), or remotely.

• Note that you need to bring your own mouse to use them directly.

• More details in a few slides.

5 / 36

Page 10: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Getting started with Java

Page 11: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Main solutions

Using Network 8 computers (reference environment)

• Requires an account on these machines

• (remote usage only) Requires a text editor, a SSH client and a (S)FTP client

(Linux/macOS) Using javac/java directly on your own computer

• Requires installation of Java SE (Standard Edition)

• Requires a text editor

Using an IDE (Integrated Development Environment), like Eclipse

• Requires installation of Java SE (Standard Edition)

• Requires installation of said IDE

How you can use Linux without changing your OS will also be discussed

6 / 36

Page 12: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Network 8

Page 13: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Network 8

A set of computers located here in Montefiore Institute in two rooms

• Room I.99

• Room "Bibliothèque" (second floor, shortly before I.99)

• Roughly 18 computers (from ms801 to ms818 as of January 2018)

Can be used directly or remotely

Run with a Linux distribution (Ubuntu)

• Therefore, tools and interface are very similar to the B37 computers.

• Those who followed INFO2009 or INFO0946 should be familiar with them.

• Provide Java 8.

To use them, you need to log in with an account.

7 / 36

Page 14: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Montefiore account

Grants you access and a personal directory on Network 8 computers.

• It works just like pmli accounts on B37 computers.

• Except you can access them anytime (lunch time, before a course, etc.).

• Note that the disk space allocated for each user is limited to 500 Mo.

• You also have to bring your own mouse or borrow one (caution: 10C).

You can create an account online.

• Go to http://www.student.montefiore.ulg.ac.be/accounts.php

• Provide your ULg registration number2 and ULg password.

Create your account as soon as possible.

You can access your directory from any machine.

2FR: votre matricule, au format sXXXXXX8 / 36

Page 15: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Remote access on Network 8

To use Network 8 computers remotely, you’ll need the following software.

• A text editor with code coloration to create and edit your Java code

• A (S)FTP client to transfer your .java files between your computer and the Network 8

• A SSH client to open a remote terminal on a Network 8 computer

Some good text editors

• Windows - Notepad++

• macOS - TextWrangler

• GNU/Linux - Geany

• Alternatively, on Debian/Ubuntu, you can use gedit.

9 / 36

Page 16: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

File transfer with Network 8

You have to use the SFTP protocol to transfer your .java files on Network 8.

Simplest method: use FileZilla .

FileZilla is available for any common operating system.

Note for macOS and GNU/Linux

Debian/Ubuntu - filezilla package.

Another solution (“expert” level):

$ scp [-r] files [email protected]:remote_dir

Further information: man scp.

10 / 36

Page 17: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Network 8 - FileZilla

FileZilla GUI (Graphical User Interface) (under Windows)

11 / 36

Page 18: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Network 8 - FileZilla (II)

(1) FileZilla log: displays the connexion and operations in details.

• Fast connection form (see next slide) is located just above.

(2) Local file system: your file system, in a tree view.

(3) Remote file system: file system of the remote host (after connection).

(4) Local directory: displays the content of one of your directories.

• Do a double left click on a file to send it (right click for more options).

(5) Remote directory: does the same for a directory on the remote host.

• Do a double left click on a file to download it (right click for more options).

(6) Queue: if you handle several files at once, displays the transfer queue.

12 / 36

Page 19: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Network 8 - FileZilla (III)

Example of connection to ms803 by the student user:

Host (1): sftp://ms803.montefiore.ulg.ac.be

Username (2): student

Password (3): password

13 / 36

Page 20: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Network 8 - FileZilla (IV)

This message usually appears at your first connection.

You just have to check the box to avoid this message.

Note: this message will pop for each distinct ms8xx.

14 / 36

Page 21: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Network 8 - Remote terminal

You have to use the SSH protocol to open a remote terminal on Network 8.

Windows - Use PuTTY , a free SSH client.

macOS and GNU/Linux - Use the ssh command.

In any case, you will have to use command lines. If you are new to them:

• A short tutorial (in French) .

• Pay attention to the commands: man, ls, cd, mkdir, pwd, mv, cp, less and rm.

15 / 36

Page 22: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Network 8 - PuTTY

Unlike most programs, you don’t have to install PuTTY.

You might however get a security warning when running it.

Accept to run the program.

16 / 36

Page 23: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Network 8 - PuTTY (II)

A small window with a lot of menus will open.

Type the address of a Network 8 machine in "Host" and click on "Open".

• In the example, ms801.montefiore.ulg.ac.be.

17 / 36

Page 24: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Network 8 - PuTTY (III)

Like with FileZilla, you will get a small warning.

Just tell you trust the remote host by clicking "Yes".

This happens only once for each ms8XX machine.

18 / 36

Page 25: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Network 8 - PuTTY (IV)

A terminal will open. Enter your credentials3.

You can now interact with the remote host with command lines.

3FR: identifiants de connexion19 / 36

Page 26: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Network 8 - ssh command

Just run this command:

$ ssh [email protected]

Replace student with your Montefiore username.

Replace XX with two digits matching a machine (01 to 18).

If a security warning appears, just reply "yes" to continue connecting.

Enter your password and you’re set to interact remotely with Network 8.

Linux - If ssh command is not recognized, install OpenSSH.

$ sudo apt-get install openssh-client

20 / 36

Page 27: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Network 8 - ssh command (II)

21 / 36

Page 28: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Beware of plagiarism !

On Network 8, anyone can access your user directory !

Hopefully, you can create directories that only you can access and manage.

Create one for your Java files (for instance: INFO0062).

Protect this directory with the appropriate rights, using this command:

$ mkdir INFO0062 && chmod 700 INFO0062

Verification:

$ ls -l...drwx------ 7 student student 4096 12 fév 02:54 INFO0062...

22 / 36

Page 29: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java SE installation

Page 30: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Java SE installation

Windows/macOS:

• Download and installation of the JRE

• Download and installation of the JDK

GNU/Linux:

• The links above offer archives compatible with any distribution.

• For an easiest solution, take a look at the repositories of your distribution.

• You can also take a look at the documentation (or the wiki) of your distribution.

• Procedure for Ubuntu (or derived)

23 / 36

Page 31: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

For macOS and Linux users

You will be able to use javac and java in the terminal after installation.

Don’t forget to get a code editor to write your code (if not using Eclipse).

• macOS - TextWrangler

• GNU/Linux - Geany

• Alternatively, on Debian/Ubuntu, you can use gedit.

This is the most direct way to code in Java if you use one of these OSes.

24 / 36

Page 32: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Eclipse, an IDE

Page 33: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

About Eclipse

Eclipse is an Integrated Development Environment.

It’s a program specifically designed for software development. It provides

• a code editor (with code coloration)

• compilation and debugging tools

• project management, auto-completion, etc.

For those who followed INFO2009 or INFO0946, it’s like Code::Blocks.

Eclipse is a very simple solution to program in Java under Windows.

• macOS/Linux users can use it too, but using java/javac is a simpler approach.

• Eclipse can however be arguably more practical for large-scale projects.

25 / 36

Page 34: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Installation

Download URL

Choose “Download Packages”.

Choose “Eclipse IDE for Java Developers”.

Be careful, you must not take the Java EE edition !

• EE = Enterprise Edition

GNU/Linux - Take a look at the repositories of your distribution.

Debian/Ubuntu - download and install eclipse package.

26 / 36

Page 35: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Project creation

Click on the black arrow delimited by the red frame.

Choose “Java Project”.

27 / 36

Page 36: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Eclipse project creation (II)

Enter your project name (1).

Click on “Finish”.

28 / 36

Page 37: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Program execution

Press the play button (no argument).

29 / 36

Page 38: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Program execution (II)

Choose “Java Application”.

Click on “OK”.

30 / 36

Page 39: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Eclipse project on Network 8 - How can I test my project ?

Suppose that you want to test an Eclipse project on Network 8.

By default, Eclipse creates a bin and a src folder for each project.

You just have to transfer the src folder and run javac on its files.

On a remote terminal, you can just run these commands:

$ javac src/*.java$ java -cp src MyMain

You can create and use a bin directory to isolate .class files from .java files.

$ mkdir bin$ javac -d bin src/*.java$ java -cp bin MyMain

Note: each time you modify your code, you have to re-transfer the edited files.

31 / 36

Page 40: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

About Linux

Page 41: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

A few words on Linux

At this point in your cursus, you have heard about Linux a lot.

• Teacher(s) introduced you to the Linux terminal and its command lines.

• You most probably had laboratory sessions with Linux distributions.

• ... and maybe some zealots tried to convert you to Linux !

Why is it a big deal in computer science ?

• Most Linux distributions are free.

• Programming under Linux is usually much easier.

• This is especially true for simple programs.

• With practice, using a terminal is also handier4 than a GUI.

Computer scientists should consider using Linux.

4FR: plus pratique, plus commode32 / 36

Page 42: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

How can I use Linux ?

You can use Linux without modifying or dumping your current OS.

• Running a Linux distribution in a virtual machine (FR)

• Using a bootable USB stick (EN)

You can also dual boot (FR) your computer.

• Both your original OS and Linux will co-exist on your computer.

• You will select the OS to run when powering-up your computer.

• Requires to partition your disk space.

• Don’t do this immediatly if you are unsure about your disk.

33 / 36

Page 43: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Which Linux distribution should I pick ?

Typically, Ubuntu ("Linux for human beings") is recommended for beginners.

• Has a complete GUI for browsing files and running programs, and even a store

• Terminal is not essential for a beginner to use it

Other popular distributions with GUI you can use

• Mint

• Fedora

34 / 36

Page 44: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Summary

Page 45: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Summary

Consider doing the following steps after this session:

• Install Java (JRE + JDK) on your own machine.

• Consider installing Eclipse if you are a Windows user.

• Create a Network 8 account.

• Download the software you need for remote interaction.

• On your Network 8 folder, create a protected directory for your .java files.

• Create a test program, then try it on the Network 8.

What kind of test program can I do ?

• Simply create a Test class (or any other name) with a main() method.

• Inside the method, print some text with System.out.println().

35 / 36

Page 46: INFO0062 - Object-Oriented Programminggrailet/docs/INFO0062/2017-2018/... · Compilation and execution of a Java program.java Compiler Execution ... Requires a text editor, a SSH

Java Java and INFO0062 Getting started with Java Network 8 Java SE installation Eclipse, an IDE About Linux Summary

Example of a test program

public class Test{

public static void main(String[] args){

System.out.println("Livin’ easy, livin’ free");System.out.println("Season ticket on a one way ride");System.out.println("Asking nothing, leave me be");System.out.println("Taking everything in my stride");System.out.println("Don’t need reason, don’t need rime");System.out.println("Ain’t nothing I would rather do");System.out.println("Going down, for a time");System.out.println("My friends are gonna be there too\n");System.out.println("I’m on the highway to hell");

}}

36 / 36