Programming in Java with Eclipse

Total Page:16

File Type:pdf, Size:1020Kb

Programming in Java with Eclipse INFO0062 - Object-Oriented Programming Programming in Java with Eclipse Jean-François Grailet University of Liège Faculty of Applied Sciences Academic Year 2018 - 2019 Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse 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. 1 / 17 Installation of Java and Eclipse Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse How to install Eclipse You will need to: • install Java on your computer • install Eclipse itself To install Java SE (Standard Edition), you can • Windows/macOS: download it on Oracle’s website. • Linux: install it via an online repository. N.B.: Java’s lattest versions are 64-bit only. • I.e., only compatible with a device that has a 64-bit hardware. Hopefully, most computers (including laptops) are 64-bit nowadays. If your device is quite old, it might be worth to double check it. • N.B.: quite old here means more than several years (e.g. 5). 2 / 17 Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse How to install Java SE Windows/macOS • Download and install Java SE 11 • 32-bit Windows: download and install Java SE Development Kit 8u201 for x86 Linux • You can use an online repository to download and install Java SE 11 • 32-bit devices: prefer using your OS’ default repositories. $ sudo apt-get update $ sudo apt-get install default-jre $ sudo apt-get install default-jdk 3 / 17 Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse Installation of Eclipse Visit Eclipse’s official website Click on “Download Packages” (below main download button). Download a version in “Eclipse IDE for Java Developers”. Be careful, you must not take the Java EE edition ! • EE = Enterprise Edition Under Ubuntu and alike (Linux), you can also run $ sudo apt-get install eclipse 4 / 17 Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse Installation of Eclipse (II) The file you downloaded is an archive. Just unzip it and place its contents in a folder of your choice. To run Eclipse, just run the application file at the root of the unzipped folder. • Don’t hesitate to create a shortcut on your desktop towards this file. N.B.: it’s possible that Eclipse doesn’t run at first launch. • See next slide. 5 / 17 Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse Troubleshooting Eclipse start-up Eclipse refuses to start because it can’t find Java. To fix this, you need to edit the eclipse.ini file. Said file is located in the same folder as the application file. Before the -vmargs line, add this: -vm C:/Program Files/Java/jdk-11.0.2/bin/javaw.exe You might have to change the second line. • It’s the path to a file that was installed with Java. • Browse your computer to find it if this path doesn’t work. • The path might still be very similar. 6 / 17 Creating a project in Eclipse Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse Creating your workspace When you first use it, Eclipse will ask you to select a workspace. This workspace is a folder where Eclipse will place all its files. • This includes project data, but also your source .java files. In your computer, create such a folder (wherever you wish). • For instance, you can create INFO0062 in your Documents. 7 / 17 Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse Creating your workspace (II) Select it in Eclipse. Check the box to ensure Eclipse don’t ask you again about this folder. 8 / 17 Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse Your first project in Eclipse Eclipse will welcome you with a variety of options. Select “Create a new Java project”. 9 / 17 Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse Your first project in Eclipse (II) Enter a project name and click on Finish. 10 / 17 Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse Your first project in Eclipse (III) At first, your project will be empty. Note that Eclipse might suggest you to create a first module. • You can completely ignore this suggestion. • Click on Don’t create it. To add a new .java file, right-click on your project. • It’s located in the left column of your screen. Unfold the New menu and select File. 11 / 17 Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse Your first project in Eclipse (IV) Make double sure the file will be saved in the src folder. Then, give it a name (e.g.: HelloWorld) and suffix it with .java. 12 / 17 Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse Your first project in Eclipse (V) For a quick test, write a single main() method. Note that compilation errors/warnings, if any, will appear in the bottom panel. 13 / 17 Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse Your first project in Eclipse (VI) Compile and run it by clicking on the green play button. The message printed by your main() will appear in the bottom panel. 14 / 17 Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse Closing comments Depending on the situation, various dialogs might appear. For instance, there might be one if you want to compile/run an unsaved file. Just read carefully the messages when this occurs. • In this specific case, allow Eclipse to save your file(s). 15 / 17 Program arguments in Eclipse Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse Program arguments in Eclipse You can pass arguments to a Java program upon starting it. We will see during the semester some practical uses of this mechanism. To pass arguments in Eclipse, perform a right click on the Run button. In the menu that dropped, select "Run Configurations...". 16 / 17 Installation of Java and Eclipse Creating a project in Eclipse Program arguments in Eclipse Program arguments in Eclipse (II) Go to the Arguments tab. Enter the argument(s) to transmit in Program arguments. Finish by clicking on Run at the bottom of the window. 17 / 17.
Recommended publications
  • How to Create an Android Application Using Eclipse on Windows 7
    How to Create an Android Application using Eclipse on Windows 7 Kevin Gleason 11/11/11 This application note is design to teach the reader how to setup an Android Development Environment on a Windows 7 Computer using eclipse and how to create an Android application. It first explains all of the software and hardware requirements and explains to the reader how to setup and install each of the required programs. It then explains how to design and code an Android application. Finally it explains how to use the Android Virtual Device to test the application. Table of Contents 1 Key Terms ..................................................................................................................................... 2 2 Objective ....................................................................................................................................... 2 3 System Requirements ................................................................................................................... 2 4 Installation and Configuration ...................................................................................................... 3 4.1 Download and Configure Eclipse IDE .................................................................................... 3 4.2 Download Android SDK ......................................................................................................... 4 4.3 Install ADT plugin for eclipse ................................................................................................. 5 4.4 Configure
    [Show full text]
  • An Intro to Eclipse Che Next-Generation Eclipse IDE & Open Source Alternative to Intellij
    An Intro to Eclipse Che Next-Generation Eclipse IDE & Open Source Alternative to IntelliJ January 2016 Tyler Jewell, Eclipse Che Project Lead @TylerJewell The Application Trinity Develop Apps Deliver Apps Host Apps check out & issue mgmt source code repo unit test quality control test build code pre-production agile ide package & integration deploy to test production archiving testing environment deploy to pre- acceptance deploy to production testing production continuous packaging & code quality integration build tools analysis testing artifact release mgmt workspace frameworks repository 100 firms including Atlassian, JetBrains, Puppet, Chef, Ansible, ZeroTurnaround, IBM, Electric Cloud, Coverity, Sonatype, JFrog, and so on... Big Hairy Audacious Goal Let anyone contribute to any project anywhere at any time. no pre-installation required ready to participate in any branch flow always compiles and runs How http://someurl/factory?id=a_project 1. Create new, or load existing, workspace 2. Populate workspace with projects 3. Fetch source 4. Inject tools (compiler, ssh, intellisense) 5. Create runtime 6. Onboard developer into workspace A New Workspace Is Needed Eclipse Che - Next Generation Eclipse IDE Che: IDE + Workspace Server + Plug-Ins Cloud IDE Collaborative WS Server Plug-In Framework A no-installation browser IDE and Host Eclipse Che as a workspace Che includes a growing set of plug- IOE accessible from any local or server. Share tools, runtime and ins. You can also create and remote device. Thin, fast, and programming services across
    [Show full text]
  • A Strategy for Addressing the Needs of Advanced Scientific Computing Using Eclipse As a Parallel Tools Platform
    A Strategy for Addressing the Needs of Advanced Scientific Computing Using Eclipse as a Parallel Tools Platform Gregory R. Watson Craig E. Rasmussen Los Alamos National Laboratory P.O. Box 1663, MS B287 Los Alamos, NM 87545 December 2005 LA-UR-05-9114 ABSTRACT If parallel computer systems are to achieve the kinds of productivity improvements necessary to meet the needs of high productivity computing systems (HPCS), then a radical change will be required in how tools are developed for programmers and users of these systems. The number and complexity of tools is making it difficult for developers to access and use the tools effectively, and the lack of a common tool infrastructure significantly complicates tool development efforts. The rapid pace of change means that developing and maintaining the kinds of tools that will be needed to effectively utilize the capacity of future advanced computer systems is an increasingly onerous task. This paper proposes a strategy that will lead directly to productivity and quality improvements in the development and use of parallel applications, and that will provide a framework to guide and foster future tool development. This strategy is based on using the Eclipse platform to form the foundation of an integrated environment for parallel application development. The intention is not just to produce another set of tools, however, but rather to use Eclipse as both a focal point for tool development, and as a platform for producing highly integrated tools that are needed to meet the future needs of the HPC community. A Strategy for Addressing the Needs of Advanced Scientific Computing Using Eclipse as a Parallel Tools Platform 1 1 INTRODUCTION As high productivity computing systems (HPCS) are developed to meet the demands and computational challenges facing advanced scientific research, it is becoming increasingly apparent that existing software infrastructure and tools will need to be substantially improved in order to achieve the goal of sustained performance on terascale machines [17].
    [Show full text]
  • Installing a Development Environment
    IBM TRIRIGA Anywhere Version 10 Release 4.2 Installing a development environment IBM Note Before using this information and the product it supports, read the information in “Notices” on page 13. This edition applies to version 10, release 4, modification 2 of IBM TRIRIGA Anywhere and to all subsequent releases and modifications until otherwise indicated in new editions. © Copyright IBM Corporation 2014, 2015. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents Chapter 1. Preparing the IBM TRIRIGA Trademarks .............. 15 Anywhere environment ........ 1 Installing the Android development tools..... 1 Installing the iOS development tools ...... 3 Installing the Windows development tools .... 5 Chapter 2. Installing IBM TRIRIGA Anywhere .............. 7 Chapter 3. Installing an integrated development environment ....... 9 Chapter 4. Deploying apps by using MobileFirst Studio .......... 11 Notices .............. 13 Privacy Policy Considerations ........ 14 © Copyright IBM Corp. 2014, 2015 iii iv Installing a development environment Chapter 1. Preparing the IBM TRIRIGA Anywhere environment Before you can build and deploy the IBM® TRIRIGA® Anywhere Work Task Management app, you must set up the computer on which IBM TRIRIGA Anywhere is installed. Procedure 1. Prepare the environment for building the app: Android Install the Android development tools. iOS Install the iOS development tools. Windows Install the Windows development tools 2. Install IBM TRIRIGA Anywhere 3. Optional: Install an integrated development environment. 4. Deploy the app with MobileFirst Studio. Installing the Android development tools Oracle JDK and Android SDK are required to build Android mobile apps. About this task If you install the integrated development environment, which includes MobileFirst Studio and Eclipse, you must also install the Android Development Tools (ADT) plug-in.
    [Show full text]
  • Eclipse Project Briefing Materials
    [________________________] Eclipse project briefing materials. Copyright (c) 2002, 2003 IBM Corporation and others. All rights reserved. This content is made available to you by Eclipse.org under the terms and conditions of the Common Public License Version 1.0 ("CPL"), a copy of which is available at http://www.eclipse.org/legal/cpl-v10.html The most up-to-date briefing materials on the Eclipse project are found on the eclipse.org website at http://eclipse.org/eclipse/ 200303331 1 EclipseEclipse ProjectProject 200303331 3 Eclipse Project Aims ■ Provide open platform for application development tools – Run on a wide range of operating systems – GUI and non-GUI ■ Language-neutral – Permit unrestricted content types – HTML, Java, C, JSP, EJB, XML, GIF, … ■ Facilitate seamless tool integration – At UI and deeper – Add new tools to existing installed products ■ Attract community of tool developers – Including independent software vendors (ISVs) – Capitalize on popularity of Java for writing tools 200303331 4 Eclipse Overview Another Eclipse Platform Tool Java Workbench Help Development Tools JFace (JDT) SWT Team Your Tool Plug-in Workspace Development Debug Environment (PDE) Their Platform Runtime Tool Eclipse Project 200303331 5 Eclipse Origins ■ Eclipse created by OTI and IBM teams responsible for IDE products – IBM VisualAge/Smalltalk (Smalltalk IDE) – IBM VisualAge/Java (Java IDE) – IBM VisualAge/Micro Edition (Java IDE) ■ Initially staffed with 40 full-time developers ■ Geographically dispersed development teams – OTI Ottawa, OTI Minneapolis,
    [Show full text]
  • Top Productivity Tips for Using Eclipse for Embedded C/C++ Developers
    Top Productivity Tips for Using Eclipse for Embedded C/C++ Developers Garry Bleasdale, QNX Software Systems, [email protected] Andy Gryc, QNX Software Systems, [email protected] Introduction This paper presents a selection of Eclipse IDE tips and tricks gathered from: the QNX® development community: our engineers, techies and trainers Foundry27, the QNX Community Portal for open development, where we have an Eclipse IDE forum Eclipse.org forums public web sites and blogs that offer Eclipse-related expertise The 27 tips described in this paper are the tips that we received from these sources and identified as most interesting and useful to developers. We present them here with the hope that they will help make you more productive when you use the Eclipse IDE. About Eclipse A modern embedded system may employ hundreds of software tasks, all of them sharing system resources and interacting in complex ways. This complexity can undermine reliability, for the simple reason that the more code a system contains, the greater the probability that coding errors will make their way into the field. (By some estimates, a million lines of code will ship with at least 1000 bugs, even if the code is methodically developed and tested.) Coding errors can also compromise security, since they often serve as entry points for malicious hackers. No amount of testing can fully eliminate these bugs and security holes, as no test suite can anticipate every scenario that a complex software system may encounter. Consequently, system designers and software developers must adopt a “mission-critical mindset” and employ software architectures that can contain software errors and recover from them quickly.
    [Show full text]
  • Eclipse (Software) 1 Eclipse (Software)
    Eclipse (software) 1 Eclipse (software) Eclipse Screenshot of Eclipse 3.6 Developer(s) Free and open source software community Stable release 3.6.2 Helios / 25 February 2011 Preview release 3.7M6 / 10 March 2011 Development status Active Written in Java Operating system Cross-platform: Linux, Mac OS X, Solaris, Windows Platform Java SE, Standard Widget Toolkit Available in Multilingual Type Software development License Eclipse Public License Website [1] Eclipse is a multi-language software development environment comprising an integrated development environment (IDE) and an extensible plug-in system. It is written mostly in Java and can be used to develop applications in Java and, by means of various plug-ins, other programming languages including Ada, C, C++, COBOL, Perl, PHP, Python, Ruby (including Ruby on Rails framework), Scala, Clojure, and Scheme. The IDE is often called Eclipse ADT for Ada, Eclipse CDT for C/C++, Eclipse JDT for Java, and Eclipse PDT for PHP. The initial codebase originated from VisualAge.[2] In its default form it is meant for Java developers, consisting of the Java Development Tools (JDT). Users can extend its abilities by installing plug-ins written for the Eclipse software framework, such as development toolkits for other programming languages, and can write and contribute their own plug-in modules. Released under the terms of the Eclipse Public License, Eclipse is free and open source software. It was one of the first IDEs to run under GNU Classpath and it runs without issues under IcedTea. Eclipse (software) 2 Architecture Eclipse employs plug-ins in order to provide all of its functionality on top of (and including) the runtime system, in contrast to some other applications where functionality is typically hard coded.
    [Show full text]
  • Comparative Studies of 10 Programming Languages Within 10 Diverse Criteria
    Department of Computer Science and Software Engineering Comparative Studies of 10 Programming Languages within 10 Diverse Criteria Jiang Li Sleiman Rabah Concordia University Concordia University Montreal, Quebec, Concordia Montreal, Quebec, Concordia [email protected] [email protected] Mingzhi Liu Yuanwei Lai Concordia University Concordia University Montreal, Quebec, Concordia Montreal, Quebec, Concordia [email protected] [email protected] COMP 6411 - A Comparative studies of programming languages 1/139 Sleiman Rabah, Jiang Li, Mingzhi Liu, Yuanwei Lai This page was intentionally left blank COMP 6411 - A Comparative studies of programming languages 2/139 Sleiman Rabah, Jiang Li, Mingzhi Liu, Yuanwei Lai Abstract There are many programming languages in the world today.Each language has their advantage and disavantage. In this paper, we will discuss ten programming languages: C++, C#, Java, Groovy, JavaScript, PHP, Schalar, Scheme, Haskell and AspectJ. We summarize and compare these ten languages on ten different criterion. For example, Default more secure programming practices, Web applications development, OO-based abstraction and etc. At the end, we will give our conclusion that which languages are suitable and which are not for using in some cases. We will also provide evidence and our analysis on why some language are better than other or have advantages over the other on some criterion. 1 Introduction Since there are hundreds of programming languages existing nowadays, it is impossible and inefficient
    [Show full text]
  • Setting up and Customizing Code::Blocks (CS 1428 Guide)
    Setting Up and Customizing Code::Blocks (CS 1428 Guide) Table of Contents Setting up Code::Blocks – Getting Started .............................................................................................................. 2 Using a single source file without a project ............................................................................................................ 2 Creating the source file ................................................................................................................................... 2 Compiling the source file ................................................................................................................................ 4 Using a project ....................................................................................................................................................... 5 Making a new project ..................................................................................................................................... 5 Renaming the source file ................................................................................................................................ 7 Compiling the source file ................................................................................................................................ 7 Creating Input Files with the Editor ........................................................................................................................ 8 Customizing the Editor ...........................................................................................................................................
    [Show full text]
  • Swapping Your IDE in Eclipse Che
    Swapping your IDE in Eclipse Che Sergii Kabashniuk Principal Software Engineer, DevTools Red Hat Tools evolution http://devichedesigns.com/work/tool-evolution 2 3 4 5 Punch cards 6 Punch cards IDE 7 8 Wikipedia “In 1995 IDE was not well received by developers since it would fence in their creativity. 9 What are the trends ? 10 11 A new generation of IDEs Developers love them because of : ● Lightweight ● Simplicity ● Powerful tooling ● Easy customization ● High release cadence 12 The VScode example ● <100Mb download ● Light UI ● Marketplace ● Extensions, Language Servers ● Each month a new version 13 And other light editors And new Atom IDE 14 Not afraid anymore by... browser IDE 15 CodeSendbox 16 Eclipse Theia 17 Eclipse Che 18 127 Releases 19 Anyone, anytime can contribute to a project without installing software. Che’s Workspaces IDE Project Files Runtimes 21 Tools Packaged as Sidecars Keeps application containers “untouched” JDT Sidecars are bringing their dependencies App (compared to VSCode) Isolated execution Own lifecycle IDE Easy upgrade/switch Simpler packaging Debugger Scalability Test Application stack + Sidecars 22 Devfile format New Specification for Dev Environments for the cloud Yaml Format 3 Parts ● Projects ● Tools ● Commands 23 New Plugin Formats PLUGIN SYSTEM SWAPPABLE CONTAINER BASED FOR EDITORS THEIA/VS CODE 24 INSERT DESIGNATOR, IF NEEDED Deliver Your plugins Public In-house Administration Che plugins marketplace for and teams registry enterprise capabilities (with stats) 25 Demo 26 GTK+ with Broadway 27 NoVNC Container Browser Gedit IntelliJ fluxbox X11vnc xvfb supervisord noVNC 28 29 Problems ● Authentication/Authorization ● Arbitrarily assigned user ID ● Access to parent frame ● Screen size 30 Get started with Eclipse Che Sources Dev List [email protected] github.com/eclipse/che IRC Mattermost https://mattermost.eclipse.org/ #eclipseche 31 THANK YOU plus.google.com/+RedHat facebook.com/redhatinc linkedin.com/company/red-hat twitter.com/RedHatNews youtube.com/user/RedHatVideos.
    [Show full text]
  • Android Programming Cookbook I
    Android Programming Cookbook i Android Programming Cookbook Android Programming Cookbook ii Contents 1 Android Tutorial For Beginners 1 1.1 What is Android?...................................................1 1.2 Installing Android Studio...............................................1 1.3 Android versions and Android SDK Manager....................................7 1.4 Supporting different screen sizes...........................................7 1.5 Android Project Structure...............................................8 1.6 Create "Hello Android World" application......................................9 1.6.1 Create a New Android Studio Project....................................9 1.6.2 Create the source code of a simple FirstAndroidApplication Activity.................... 13 1.6.3 Create the layout of the project........................................ 14 1.6.4 Android Manifest............................................... 14 1.6.5 Edit the FirstAndroidApplication dimensions................................ 15 1.6.6 Edit the FirstAndroidApplication strings................................... 15 1.6.7 Add the drawable for every screen density.................................. 15 1.6.8 Build, compile and run............................................ 16 1.7 Download the Android Studio Project........................................ 18 1.8 How to continue?................................................... 18 2 Android Project migration from Eclipse to Android Studio 19 2.1 Why to use Android Studio over Eclipse ADT?..................................
    [Show full text]
  • Integrated Virtual Debugger for Eclipse Developer's Guide
    Integrated Virtual Debugger for Eclipse Developer’s Guide VMware Workstation 7.0 This document supports the version of each product listed and supports all subsequent versions until the document is replaced by a new edition. To check for more recent editions of this document, see http://www.vmware.com/support/pubs. EN-000172-00 Integrated Virtual Debugger for Eclipse Developer’s Guide You can find the most up-to-date technical documentation on the VMware Web site at: http://www.vmware.com/support/ The VMware Web site also provides the latest product updates. If you have comments about this documentation, submit your feedback to: [email protected] Copyright © 1998-2009 VMware, Inc. All rights reserved. This product is protected by U.S. and international copyright and intellectual property laws. VMware products are covered by one or more patents listed at http://www.vmware.com/go/patents. VMware is a registered trademark or trademark of VMware, Inc. in the United States and/or other jurisdictions. All other marks and names mentioned herein may be trademarks of their respective companies. VMware, Inc. 3401 Hillview Ave. Palo Alto, CA 94304 www.vmware.com 2 VMware, Inc. Contents About This Book 5 1 Using the Integrated Virtual Debugger for Eclipse 7 Debugging Environment of the Integrated Virtual Debugger 7 Installation Requirements of the Integrated Virtual Debugger for Eclipse 8 Host System Requirements 8 Supported Host Operating Systems 8 Supported JRE Versions 9 Eclipse Requirements 9 Installing and Uninstalling the Integrated Virtual
    [Show full text]