A web-based IDE for Java

Similar documents
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java

Java language. Part 1. Java fundamentals. Yevhen Berkunskyi, NUoS

COMP 202 Java in one week

3. Java - Language Constructs I

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

CSC 1214: Object-Oriented Programming

Building Java Programs. Introduction to Programming and Simple Java Programs

Java Programming. Atul Prakash

Computer Components. Software{ User Programs. Operating System. Hardware

An overview of Java, Data types and variables

Welcome to CSE 142! Whitaker Brand. University of Washington, Winter 2018

2 rd class Department of Programming. OOP with Java Programming

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

Language Fundamentals Summary

CSCI 2101 Java Style Guide

Welcome to CSE 142! Zorah Fung University of Washington, Spring Building Java Programs Chapter 1 Lecture 1: Introduction; Basic Java Programs

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

CompSci 125 Lecture 02

Introduction to Programming Using Java (98-388)

Java: framework overview and in-the-small features

Computer Components. Software{ User Programs. Operating System. Hardware

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA

ECE 122 Engineering Problem Solving with Java

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Last Time. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings

Chapter. Focus of the Course. Object-Oriented Software Development. program design, implementation, and testing

CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

The keyword list thus far: The Random class. Generating "Random" Numbers. Topic 16

Topic 16. battle -they are strictly limited in number, they require fresh horses, and must only be made at decisive moments." -Alfred North Whitehead

-Alfred North Whitehead. Copyright Pearson Education, 2010 Based on slides by Marty Stepp and Stuart Reges from

Lecture 2: Variables and Operators. AITI Nigeria Summer 2012 University of Lagos.

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Java is a high-level programming language originally developed by Sun Microsystems and released in Java runs on a variety of

The MaSH Programming Language At the Statements Level

1.Which four options describe the correct default values for array elements of the types indicated?

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p.

MP 3 A Lexer for MiniJava

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Imports. Lexicon. Java/Lespérance 1. PROF. Y. LESPÉRANCE Dept. of Electrical Engineering & Computer Science

Accelerating Information Technology Innovation

Building Java Programs. Chapter 1: Introduction to Java Programming

The Java Language The Java Language Reference (2 nd ed.) is the defining document for the Java language. Most beginning programming students expect

: Primitive data types Variables Operators if, if-else do-while, while, for. // // First Java Program. public class Hello {

Games Course, summer Introduction to Java. Frédéric Haziza

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

3. Java - Language Constructs I

Getting started with Java

DM550 Introduction to Programming part 2. Jan Baumbach.

Index COPYRIGHTED MATERIAL

Java Programming with Eclipse

Spell Checker for EiffelStudio

Chapter 2. Elementary Programming

Java Overview An introduction to the Java Programming Language

PROGRAMMING FUNDAMENTALS

Entering the world of Javatar

C#: framework overview and in-the-small features

Introduction to C# Applications

STRUCTURING OF PROGRAM

Introduction to Programming (Java) 2/12

Java Programming Language Mr.Rungrote Phonkam

Lecture 1: Basic Java Syntax

Variables. Data Types.

JAVA Ch. 4. Variables and Constants Lawrenceville Press

CSC Java Programming, Fall Java Data Types and Control Constructs

Basic Types, Variables, Literals, Constants

Programming Lecture 3

Selected Java Topics

COP 3330 Final Exam Review

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Introduction to Computing II (ITI 1121) Final Examination

About this exam review

Java Classes. Produced by. Introduction to the Java Programming Language. Eamonn de Leastar

Introduction to Eiffel

Static Methods & Decomposition

The Sun s Java Certification and its Possible Role in the Joint Teaching Material

Programming. Syntax and Semantics

Pace University. Fundamental Concepts of CS121 1

DM503 Programming B. Peter Schneider-Kamp.

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.

Core JAVA Training Syllabus FEE: RS. 8000/-

Talend Component tgoogledrive

Declarations and Access Control SCJP tips

Developing with VMware vcenter Orchestrator. vrealize Orchestrator 5.5.1

Crash Course in Java. Why Java? Java notes for C++ programmers. Network Programming in Java is very different than in C/C++

Java TM Introduction. Renaud Florquin Isabelle Leclercq. FloConsult SPRL.

JScript Reference. Contents

Tokens, Expressions and Control Structures

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started

Programming in C++ 4. The lexical basis of C++

Program Fundamentals

CS211 Computers and Programming Matthew Harris and Alexa Sharp July 9, Boggle

6.096 Introduction to C++ January (IAP) 2009

JOSE LUIS JUAREZ VIVEROS com) has a. non-transferable license to use this Student Guide

Java Fundamentals (II)

Java 1.8 Programming

Java Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Transcription:

A web-based IDE for Java Software Engineering Laboratory By: Supervised by: Marcel Bertsch Christian Estler Dr. Martin Nordio Prof. Dr. Bertrand Meyer Student Number: 09-928-896

Content 1 Introduction...3 1.1 Motivation...3 1.2 Goal...3 2 Project Structure...3 2.1 Creation...3 2.2 Database...4 2.3 Initial Main Class Content...4 3 IDE...4 3.1 Syntax Highlighter...4 3.2 Package Explorer...5 3.2.1 Structure...5 3.2.2 Adding & Deleting...5 4 Compilation and Execution...6 4.1 Compiler...6 4.2 Running a Project...6 5 Conclusion...7 2

1 Introduction 1.1 Motivation Software development is teamwork. Therefore we need good tools which allow us to cooperate in an easy and pleasant way. Cloudstudio is such a tool; it provides not only code sharing features but also a complete IDE to develop projects. What I like most at Cloudstudio is that it is browser-based, so no additional software needs to be installed; hence compatibility is not an issue. The cloud is growing more important, local data storage will probably be less common in the future. Google Docs is a good example of how people can work together in the cloud, so why not also work with code in that way? 1.2 Goal Goal of this project is extending Cloudstudio to also provide an IDE for Java development. Java is ideal because it is frequently used and well established. It also stands for platform independence and therefore correlates well with Cloudstudio. Starting point is an IDE which is completely designed for Eiffel development. The Java version should have a look and feel similar to the Eiffel version but also be comfortable for Java programmers not used to EiffelStudio. 2 Project Structure 2.1 Creation In the New Project Dialog two new fields appear when selecting Java as a language: Package Name Main Class The user can fill in one, both or none. If both fields are used, a class containing the main method gets created in a package, both named as given by the user. If only a package name is filled in, Cloudstudio will generate an empty package. If the user provides a class name but not a package name, the system will put it into a default package. If neither is given the project will be initially empty For the RPC call the Eiffel version is reused. The package and main class name get appended to the project s name separated by spaces since all these parameters cannot contain any. The package name will always be attached and is called (default) if the user has not entered something different. This makes it possible to distinguish between package and main class name. On the server side this information gets extracted if the project s language is Java and the project accordingly created. 3

2.2 Database The database adds the following entries for a new project: Table Name Content `project` The project s name A generated id The owner s id The language The project description `documentfolders` A folder for the source code named Src with a generated id, the project s id and 0 as the parent folder s id which means the folder is at the root Another folder with the package name having the Src folder as the parent folder (if no package name is given, a (default) folder gets inserted) `source_files` The main class file (if provided) with `folder_id` pointing to the package in `documentfolders` 2.3 Initial Main Class Content Source file content is stored in the same way as used for Eiffel files, making it possible to reuse all kinds of functionalities for source code management. For a detailed description have a look at the Cloud Control 1 project by Alexandru Dima and Alejandro García. Package and class names are inserted making the initial content of the main class look like this: 3 IDE 3.1 Syntax Highlighter Syntax highlighting is realized in the new Eiffel class EVSH_JAVA inheriting from EV_SYNTAX_HIGHLIGHTER. When opening a file, the editor checks its ending. If it is.java, an instance of EVSH_JAVA is created. Keywords, types and separators are taken from the book Java in a Nutshell 2. Known types boolean, char, byte, short, int, long, float, double 1 http://cloudstudio.origo.ethz.ch/wiki/cloudcontrol 2 Java in a Nutshell 5th Edition by David Flanagan 4

Keywords Separators String/Character delimiter Escape character \ abstract, assert, boolean, break, byte, case, catch, char, class, const, continue, default, do, double, else, enum, extends, false, final, finally, float, for, goto, if, implements, import, instanceof, int, interface, long, native, new, null, package, private, protected, public, return, short, static, strictfp, super, switch, synchronized, this, throw, throws, transient, true, try, void, volatile, while ( ) { } [ ] < > : ;,. @ 3.2 Package Explorer 3.2.1 Structure In comparison to the Eiffel IDE, both the folders and the files must be loaded when opening a project. This makes the updateclusters method in class IdeGroupPresenter a bit more complicated. Since all the server database requests are asynchronous, making two separated ones would not lead to a deterministic result. The solution is combining them in a single request which returns two lists, one with folders and the other with files. Both are packed into a hash map to be sent to the client. To work with document folders in the code and database two new classes have been added: Class Name Functionalities DocumentFoldersTable Inserting a new folder into the database Get a folder from the DB by its id Get all folders of a project Delete a folder and all subfolders/-files if wanted DocumentFolderModel Represents a document folder as in the DB Contains the folder s name, its id, the parent s id and the project id First the folders get added to the TreeStore object which is used for the package explorer. Top-level folders (those with parent id 0 ) are added straightaway, sub folders not until their parent is in the structure. Added folders get deleted from the list and the process is repeated until the list is empty. A hash map keeps track of added folders by mapping their ids to the corresponding ModelData in the tree. If the parent folder is named Src, the package icon is used, a normal folder icon otherwise. In a second step the source files are added. 3.2.2 Adding & Deleting Adding and deleting packages and source files can be done by right-clicking on the parent folder/package for adding and on the element itself for deleting. The context menu always contains the two options New and Delete The action when clicked depends on the element. 5

Element New Delete Project Folder Create a new top-level folder Not supported Src Folder Create a new package Not supported Package Add a new file to the package Delete the package and all files in it Source File Not supported Delete the file Other Folders Not supported yet, might be used for library import in the future 4 Compilation and Execution 4.1 Compiler Java compilation starts in the same way as it was implemented for Eiffel projects. When the user starts the RPC by clicking the compile button, all the project s source files are read from the database and copied to the file system at location C:/Cloudstudio/[projectID]/[userID]. Now the class JavaCompiler uses java.lang.runtime and java.lang.process to create a new folder for the compiled project at C:/Cloudstudio/[projectID]/[userID]/compiled and starts javac to compile the source files. If javac exits with code 0, the user is informed that the compilation was successful. If the exit code is not equal to 0, javac s error output is sent to the client console. Unlike as in the Eiffel version, these return messages are not processed on the client side and are printed as sent by the server. Note that the JDK binary folder must be in the server s path for this to work. 4.2 Running a Project Due to security concerns it is not possible to run projects on the server. The workaround is an executable JAR archive of the project, generated by the server and sent to the user. When the user clicks the run button, a dialog appears where the name of the main class (including package) must be entered. This information is required to determine the entry point of the program and will be put into the manifest file in the archive which makes the JAR executable. The callback of the run RPC opens a new window connecting to getjarservlet mapped to GetJarService. The URL is provided by the callback and contains all information required (projected and userid) to find the JAR in the file system which then is sent to the client where the browser s standard download dialog appears. As soon as the download is completed, the JAR file on the server gets deleted and further requests with the same URL will receive a file not found error. To execute the JAR, the user can simply double-click it or type java jar [JarName].jar into the command shell. 6

cloudstudio/web-inf/web.xml com.cloudstudio.server.compiler.javacompiler.runjavaproject com.cloudstudio.server.compiler.getjarservice.doget 5 Conclusion Programmers now have a web-based IDE where they can develop Java projects together. They are able to add and delete files and packages, write code, compile it and download an executable version of their project. There are still a lot of things to do and improve; this project is to be seen as a framework for further development steps on Cloudstudio. 7