Upload
others
View
19
Download
0
Embed Size (px)
Citation preview
INFO0062 - Object-Oriented ProgrammingProgramming with Java
Jean-François Grailet
University of Liège
Faculty of Applied Sciences
Academic Year 2019 - 2020
Installing Java Programming with Java Annex: about Linux
Summary
Installing Java
Recommended solutions to get started with Java
• Using javac / java with a CLI
• Using Eclipse IDE
Annex: about Linux
• For future computer scientists
• Solutions to get started with Linux
1 / 20
Installing Java
Installing Java Programming with Java Annex: about Linux
Installing Java
No matter how you will program with Java, you have to install Java first.
Indeed, Java programs run in virtual machines.
• They are not directly compiled into executables like C or C++ programs
• Cf. Chapter 2, slides 31-32
You therefore need a compiler (javac) and a virtual machine (java).
Hopefully, you can install both of them at once.
Remark: before reading next slides, make sure you don’t have Java already.
• Use your search bar or program manager to check this.
• Note that some installations can be incomplete for this course.
E.g., they include a virtual machine but don’t come with a compiler.
• In this case, you can install the version of Java mentioned in next slides.
2 / 20
Installing Java Programming with Java Annex: about Linux
Installing Java (II)
What you want to install is the Java SE Development Kit.
• SE = Standard Edition
• Comes with both javac and java
• Current version1: 13.0.2
You can download it on Oracle’s website.
Remark: Java’s lattest version is for 64-bit hardware only.
• Hopefully, basically all computers nowadays have a 64-bit architecture.
Contact a teaching assistant if you are using a 32-bit hardware.
• We will review how to install Java on your machine.
1 i.e., at the time of creating this document3 / 20
Installing Java Programming with Java Annex: about Linux
Installing Java (III)
4 / 20
Installing Java Programming with Java Annex: about Linux
Installing Java (IV)
Upon download, don’t forget to accept the license agreement.
You can download the uncompressed installers.
You can then use them right away to install Java.
• Follow the steps normally; you don’t have anything special to do here.
5 / 20
Installing Java Programming with Java Annex: about Linux
Installing Java (V)
6 / 20
Installing Java Programming with Java Annex: about Linux
Installing Java (VI)
Linux users can also use the following commands to install Java.
Ubuntu 18.04 LTS (and onwards)
sudo apt updatesudo apt install default-jresudo apt install default-jdk
Older distributions (including 32-bit systems)
sudo apt-get updatesudo apt-get install default-jresudo apt-get install default-jdk
7 / 20
Installing Java Programming with Java Annex: about Linux
No computer ? No worries
You can use the freely accessible computers at the Montefiore Institute (B28).
• Located on the first floor, near employees’ lunch room
• They can be seen from the bridge between B28 and B37
• Run with Ubuntu; already have javac and java
• Can help you if you don’t have a laptop or your own home computer
Note that you can’t use them right away.
• You need to create a Montefiore account to log in on them.
• You also have to bring your own mouse (or rent one). 2
Contact a teaching assistant for more details on the matter.
2Some people apparently stole mouses a few years ago. God knows why.8 / 20
Programming with Java
Installing Java Programming with Java Annex: about Linux
Getting started with Java
For this course, we suggest you two approaches.
Both works on any common OS (Operating System3).
Using javac / java with a CLI
• CLI = Command Line Interface
• Also called command prompt4 under Windows
• A CLI consists in using your computer by typing text commands
Using Eclipse IDE
• IDE = Integrated Development Environment
• An IDE is a piece of software designed for developping large programs
Note that in both cases, you will have to install Java first.
3FR: système d’exploitation; exemple: Windows 104FR: invite de commandes
9 / 20
Installing Java Programming with Java Annex: about Linux
Using javac and java with a CLI
javac and java are the traditional tools to compile and run a Java program.
• javac: compiles .java files
• java: runs compiled Java programs
The reason why there are two pieces of software is Java’s design.
• javac produces bytecode (as .class files).
• This code can only be interpreted by a Java Virtual Machine (JVM).
You can use both tools with CLI under any OS (i.e., Windows, macOS, Linux).
10 / 20
Installing Java Programming with Java Annex: about Linux
Using javac and java with a CLI (II)
11 / 20
Installing Java Programming with Java Annex: about Linux
Using javac and java with a CLI (III)
Pros5
• No need to install additional software (except a text editor, if none)
• Light interface (CLI along with a text editor)
• Once you’re used to it, it’s quick and easy to use
• Perfect to compile and run small programs
Cons6
• You have to learn how to use a CLI (can be confusing at first)
• Needs to modify Windows’ settings to get it working on it
5FR: avantages6FR: désavantages
12 / 20
Installing Java Programming with Java Annex: about Linux
Using Eclipse IDE
Eclipse is a very popular IDE to create Java programs.
It’s available for any common OS.
Provides at the same time code edition and compilation/running.
Provides a rich GUI (Graphical User Interface) with many tools.
• Syntax checking
• Interface checking (i.e., checking if your methods are correctly invoked)
• Project manager (to review the architecture of a Java program)
• Spell checker7
• Etc.
7FR: correcteur orthographique13 / 20
Installing Java Programming with Java Annex: about Linux
Using Eclipse IDE (II)
14 / 20
Installing Java Programming with Java Annex: about Linux
Using Eclipse IDE (III)
Pros
• Rich GUI, comes with many useful tools
• All-in-One
• Can be more user-friendly than CLI to beginners
• Can be useful if your future courses include large Java projects
Cons
• Has to be installed in addition to Java itself
• Designed to build large Java programs
In INFO0062, we will only write small programs
15 / 20
Installing Java Programming with Java Annex: about Linux
How to choose your solution to program with Java
What’s your OS (Operating System) ?
LinuxmacOSWindows
Is Computer Science your thing ?
Is Computer Science your thing ?
Yes No No Yes
Install Java & EclipseInstall Java, modify thePATH variable and usethe command prompt
Install Java and use your terminal
16 / 20
Installing Java Programming with Java Annex: about Linux
What’s next ?
Next, read the dedicated tutorial for the solution you chose.
Also, if you are a (future) computer scientist, consider the annex.
• At this point in your studies, you might want to consider using Linux.
17 / 20
Annex: about Linux
Installing Java Programming with Java Annex: about Linux
A few words on Linux
At this point in your studies, you probably have heard about Linux a lot.
• Some teacher(s) may have introduced you to the Linux terminal.
• You might have used University computers running 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 and their code is publicly available.
• Programming under Linux is usually much easier.
• This is especially true for simple programs.
• With practice, using a terminal is also handier8 than a GUI.
Computer scientists should consider using Linux.
8FR: plus pratique, plus commode18 / 20
Installing Java Programming with Java Annex: about Linux
How can I use Linux ?
You can discover and 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 right now if you are not confident about modifying your disk.
19 / 20
Installing Java Programming with Java Annex: about Linux
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
• Has its own store to install additionnal software
• Terminal is not essential for a beginner to use it
Other popular distributions you can consider using
• Mint
• Fedora
20 / 20