Java Cookbook

Total Page:16

File Type:pdf, Size:1020Kb

Java Cookbook www.it-ebooks.info www.it-ebooks.info THIRD EDITION Java Cookbook Ian F. Darwin www.it-ebooks.info Java Cookbook, Third Edition by Ian F. Darwin Copyright © 2014 RejmiNet Group, Inc.. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/ institutional sales department: 800-998-9938 or [email protected]. Editors: Mike Loukides and Meghan Blanchette Indexer: Lucie Haskins Production Editor: Melanie Yarbrough Cover Designer: Randy Comer Copyeditor: Kim Cofer Interior Designer: David Futato Proofreader: Jasmine Kwityn Illustrator: Rebecca Demarest June 2014: Third Edition Revision History for the Third Edition: 2014-06-20: First release See http://oreilly.com/catalog/errata.csp?isbn=9781449337049 for release details. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Java Cookbook, the cover image of a domestic chicken, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. ISBN: 978-1-449-33704-9 [LSI] www.it-ebooks.info Table of Contents Preface. xiii 1. Getting Started: Compiling, Running, and Debugging. 1 1.1. Compiling and Running Java: JDK 2 1.2. Editing and Compiling with a Syntax-Highlighting Editor 3 1.3. Compiling, Running, and Testing with an IDE 4 1.4. Using CLASSPATH Effectively 14 1.5. Downloading and Using the Code Examples 17 1.6. Automating Compilation with Apache Ant 22 1.7. Automating Dependencies, Compilation, Testing, and Deployment with Apache Maven 25 1.8. Automating Dependencies, Compilation, Testing, and Deployment with Gradle 29 1.9. Dealing with Deprecation Warnings 31 1.10. Conditional Debugging Without #ifdef 33 1.11. Maintaining Program Correctness with Assertions 35 1.12. Debugging with JDB 36 1.13. Avoiding the Need for Debuggers with Unit Testing 38 1.14. Maintaining Your Code with Continuous Integration 41 1.15. Getting Readable Tracebacks 45 1.16. Finding More Java Source Code: Programs, Frameworks, Libraries 46 2. Interacting with the Environment. 51 2.1. Getting Environment Variables 51 2.2. Getting Information from System Properties 52 2.3. Learning About the Current JDK Release 54 2.4. Dealing with Operating System–Dependent Variations 55 2.5. Using Extensions or Other Packaged APIs 58 iii www.it-ebooks.info 2.6. Parsing Command-Line Arguments 59 3. Strings and Things. 67 3.1. Taking Strings Apart with Substrings 69 3.2. Breaking Strings Into Words 70 3.3. Putting Strings Together with StringBuilder 74 3.4. Processing a String One Character at a Time 76 3.5. Aligning Strings 78 3.6. Converting Between Unicode Characters and Strings 81 3.7. Reversing a String by Word or by Character 83 3.8. Expanding and Compressing Tabs 84 3.9. Controlling Case 89 3.10. Indenting Text Documents 90 3.11. Entering Nonprintable Characters 91 3.12. Trimming Blanks from the End of a String 92 3.13. Parsing Comma-Separated Data 93 3.14. Program: A Simple Text Formatter 98 3.15. Program: Soundex Name Comparisons 100 4. Pattern Matching with Regular Expressions. 105 4.1. Regular Expression Syntax 107 4.2. Using regexes in Java: Test for a Pattern 114 4.3. Finding the Matching Text 117 4.4. Replacing the Matched Text 120 4.5. Printing All Occurrences of a Pattern 121 4.6. Printing Lines Containing a Pattern 123 4.7. Controlling Case in Regular Expressions 125 4.8. Matching “Accented” or Composite Characters 126 4.9. Matching Newlines in Text 127 4.10. Program: Apache Logfile Parsing 129 4.11. Program: Data Mining 131 4.12. Program: Full Grep 133 5. Numbers. 139 5.1. Checking Whether a String Is a Valid Number 141 5.2. Storing a Larger Number in a Smaller Number 143 5.3. Converting Numbers to Objects and Vice Versa 144 5.4. Taking a Fraction of an Integer Without Using Floating Point 146 5.5. Ensuring the Accuracy of Floating-Point Numbers 147 5.6. Comparing Floating-Point Numbers 149 5.7. Rounding Floating-Point Numbers 151 5.8. Formatting Numbers 152 iv | Table of Contents www.it-ebooks.info 5.9. Converting Between Binary, Octal, Decimal, and Hexadecimal 154 5.10. Operating on a Series of Integers 155 5.11. Working with Roman Numerals 157 5.12. Formatting with Correct Plurals 161 5.13. Generating Random Numbers 163 5.14. Calculating Trigonometric Functions 165 5.15. Taking Logarithms 166 5.16. Multiplying Matrices 167 5.17. Using Complex Numbers 169 5.18. Handling Very Large Numbers 171 5.19. Program: TempConverter 174 5.20. Program: Number Palindromes 175 6. Dates and Times—New API. 179 6.1. Finding Today’s Date 182 6.2. Formatting Dates and Times 183 6.3. Converting Among Dates/Times, YMDHMS, and Epoch Seconds 185 6.4. Parsing Strings into Dates 186 6.5. Difference Between Two Dates 187 6.6. Adding to or Subtracting from a Date or Calendar 188 6.7. Interfacing with Legacy Date and Calendar Classes 189 7. Structuring Data with Java. 191 7.1. Using Arrays for Data Structuring 192 7.2. Resizing an Array 193 7.3. The Collections Framework 195 7.4. Like an Array, but More Dynamic 196 7.5. Using Generic Collections 199 7.6. Avoid Casting by Using Generics 200 7.7. How Shall I Iterate Thee? Let Me Enumerate the Ways 204 7.8. Eschewing Duplicates with a Set 206 7.9. Using Iterators or Enumerations for Data-Independent Access 207 7.10. Structuring Data in a Linked List 208 7.11. Mapping with Hashtable and HashMap 212 7.12. Storing Strings in Properties and Preferences 214 7.13. Sorting a Collection 218 7.14. Avoiding the Urge to Sort 222 7.15. Finding an Object in a Collection 224 7.16. Converting a Collection to an Array 226 7.17. Rolling Your Own Iterator 227 7.18. Stack 230 7.19. Multidimensional Structures 234 Table of Contents | v www.it-ebooks.info 7.20. Program: Timing Comparisons 236 8. Object-Oriented Techniques. 239 8.1. Formatting Objects for Printing with toString() 241 8.2. Overriding the equals() and hashCode() Methods 243 8.3. Using Shutdown Hooks for Application Cleanup 248 8.4. Using Inner Classes 250 8.5. Providing Callbacks via Interfaces 251 8.6. Polymorphism/Abstract Methods 255 8.7. Passing Values 256 8.8. Using Typesafe Enumerations 259 8.9. Enforcing the Singleton Pattern 263 8.10. Roll Your Own Exceptions 266 8.11. Using Dependency Injection 267 8.12. Program: Plotter 270 9. Functional Programming Techniques: Functional Interfaces, Streams, Parallel Collections. 275 9.1. Using Lambdas/Closures Instead of Inner Classes 278 9.2. Using Lambda Predefined Interfaces Instead of Your Own 282 9.3. Simplifying Processing with Streams 283 9.4. Improving Throughput with Parallel Streams and Collections 285 9.5. Creating Your Own Functional Interfaces 286 9.6. Using Existing Code as Functional with Method References 289 9.7. Java Mixins: Mixing in Methods 293 10. Input and Output. 295 10.1. Reading Standard Input 298 10.2. Reading from the Console or Controlling Terminal; Reading Passwords Without Echoing 300 10.3. Writing Standard Output or Standard Error 302 10.4. Printing with Formatter and printf 304 10.5. Scanning Input with StreamTokenizer 308 10.6. Scanning Input with the Scanner Class 312 10.7. Scanning Input with Grammatical Structure 316 10.8. Opening a File by Name 317 10.9. Copying a File 318 10.10. Reading a File into a String 325 10.11. Reassigning the Standard Streams 325 10.12. Duplicating a Stream as It Is Written 326 10.13. Reading/Writing a Different Character Set 329 10.14. Those Pesky End-of-Line Characters 330 vi | Table of Contents www.it-ebooks.info 10.15. Beware Platform-Dependent File Code 331 10.16. Reading “Continued” Lines 332 10.17. Reading/Writing Binary Data 336 10.18. Seeking to a Position within a File 337 10.19. Writing Data Streams from C 338 10.20. Saving and Restoring Java Objects 340 10.21. Preventing ClassCastExceptions with SerialVersionUID 344 10.22. Reading and Writing JAR or ZIP Archives 346 10.23. Finding Files in a Filesystem-Neutral Way with getResource() and getResourceAsStream() 349 10.24. Reading and Writing Compressed Files 351 10.25. Learning about the Communications API for Serial and Parallel Ports 352 10.26. Save User Data to Disk 357 10.27. Program: Text to PostScript 360 11. Directory and Filesystem Operations. 365 11.1. Getting File Information 365 11.2. Creating a File 368 11.3. Renaming a File 369 11.4. Deleting a File 370 11.5. Creating a Transient File 372 11.6. Changing File Attributes 373 11.7. Listing a Directory 375 11.8. Getting the Directory Roots 377 11.9. Creating New Directories 378 11.10. Using Path instead of File 379 11.11. Using the FileWatcher Service to Get Notified about File Changes 380 11.12.
Recommended publications
  • Toward Harnessing High-Level Language Virtual Machines for Further Speeding up Weak Mutation Testing
    2012 IEEE Fifth International Conference on Software Testing, Verification and Validation Toward Harnessing High-level Language Virtual Machines for Further Speeding up Weak Mutation Testing Vinicius H. S. Durelli Jeff Offutt Marcio E. Delamaro Computer Systems Department Software Engineering Computer Systems Department Universidade de Sao˜ Paulo George Mason University Universidade de Sao˜ Paulo Sao˜ Carlos, SP, Brazil Fairfax, VA, USA Sao˜ Carlos, SP, Brazil [email protected] [email protected] [email protected] Abstract—High-level language virtual machines (HLL VMs) have tried to exploit the control that HLL VMs exert over run- are now widely used to implement high-level programming ning programs to facilitate and speedup software engineering languages. To a certain extent, their widespread adoption is due activities. Thus, this research suggests that software testing to the software engineering benefits provided by these managed execution environments, for example, garbage collection (GC) activities can benefit from HLL VMs support. and cross-platform portability. Although HLL VMs are widely Test tools are usually built on top of HLL VMs. However, used, most research has concentrated on high-end optimizations they often end up tampering with the emergent computation. such as dynamic compilation and advanced GC techniques. Few Using features within the HLL VMs can avoid such problems. efforts have focused on introducing features that automate or fa- Moreover, embedding testing tools within HLL VMs can cilitate certain software engineering activities, including software testing. This paper suggests that HLL VMs provide a reasonable significantly speedup computationally expensive techniques basis for building an integrated software testing environment. As such as mutation testing [6].
    [Show full text]
  • A Hardware Abstraction Layer in Java
    A Hardware Abstraction Layer in Java MARTIN SCHOEBERL Vienna University of Technology, Austria STEPHAN KORSHOLM Aalborg University, Denmark TOMAS KALIBERA Purdue University, USA and ANDERS P. RAVN Aalborg University, Denmark Embedded systems use specialized hardware devices to interact with their environment, and since they have to be dependable, it is attractive to use a modern, type-safe programming language like Java to develop programs for them. Standard Java, as a platform independent language, delegates access to devices, direct memory access, and interrupt handling to some underlying operating system or kernel, but in the embedded systems domain resources are scarce and a Java virtual machine (JVM) without an underlying middleware is an attractive architecture. The contribution of this paper is a proposal for Java packages with hardware objects and interrupt handlers that interface to such a JVM. We provide implementations of the proposal directly in hardware, as extensions of standard interpreters, and finally with an operating system middleware. The latter solution is mainly seen as a migration path allowing Java programs to coexist with legacy system components. An important aspect of the proposal is that it is compatible with the Real-Time Specification for Java (RTSJ). Categories and Subject Descriptors: D.4.7 [Operating Systems]: Organization and Design—Real-time sys- tems and embedded systems; D.3.3 [Programming Languages]: Language Classifications—Object-oriented languages; D.3.3 [Programming Languages]: Language Constructs and Features—Input/output General Terms: Languages, Design, Implementation Additional Key Words and Phrases: Device driver, embedded system, Java, Java virtual machine 1. INTRODUCTION When developing software for an embedded system, for instance an instrument, it is nec- essary to control specialized hardware devices, for instance a heating element or an inter- ferometer mirror.
    [Show full text]
  • Techniques for Real-System Characterization of Java Virtual Machine Energy and Power Behavior Gilberto Contreras Margaret Martonosi
    Techniques for Real-System Characterization of Java Virtual Machine Energy and Power Behavior Gilberto Contreras Margaret Martonosi Department of Electrical Engineering Princeton University 1 Why Study Power in Java Systems? The Java platform has been adopted in a wide variety of devices Java servers demand performance, embedded devices require low-power Performance is important, power/energy/thermal issues are equally important How do we study and characterize these requirements in a multi-layer platform? 2 Power/Performance Design Issues Java Application Java Virtual Machine Operating System Hardware 3 Power/Performance Design Issues Java Application Garbage Class Runtime Execution Collection LoaderJava VirtualCompiler MachineEngine Operating System Hardware How do the various software layers affect power/performance characteristics of hardware? Where should time be invested when designing power and/or thermally aware Java virtual Machines? 4 Outline Approaches for Energy/Performance Characterization of Java virtual machines Methodology Breaking the JVM into sub-components Hardware-based power/performance characterization of JVM sub-components Results Jikes & Kaffe on Pentium M Kaffe on Intel XScale Conclusions 5 Power & Performance Analysis of Java Simulation Approach √ Flexible: easy to model non-existent hardware x Simulators may lack comprehensiveness and accuracy x Thermal studies require tens of seconds granularity Accurate simulators are too slow Hardware Approach √ Able to capture full-system characteristics
    [Show full text]
  • Return of Organization Exempt from Income
    OMB No. 1545-0047 Return of Organization Exempt From Income Tax Form 990 Under section 501(c), 527, or 4947(a)(1) of the Internal Revenue Code (except black lung benefit trust or private foundation) Open to Public Department of the Treasury Internal Revenue Service The organization may have to use a copy of this return to satisfy state reporting requirements. Inspection A For the 2011 calendar year, or tax year beginning 5/1/2011 , and ending 4/30/2012 B Check if applicable: C Name of organization The Apache Software Foundation D Employer identification number Address change Doing Business As 47-0825376 Name change Number and street (or P.O. box if mail is not delivered to street address) Room/suite E Telephone number Initial return 1901 Munsey Drive (909) 374-9776 Terminated City or town, state or country, and ZIP + 4 Amended return Forest Hill MD 21050-2747 G Gross receipts $ 554,439 Application pending F Name and address of principal officer: H(a) Is this a group return for affiliates? Yes X No Jim Jagielski 1901 Munsey Drive, Forest Hill, MD 21050-2747 H(b) Are all affiliates included? Yes No I Tax-exempt status: X 501(c)(3) 501(c) ( ) (insert no.) 4947(a)(1) or 527 If "No," attach a list. (see instructions) J Website: http://www.apache.org/ H(c) Group exemption number K Form of organization: X Corporation Trust Association Other L Year of formation: 1999 M State of legal domicile: MD Part I Summary 1 Briefly describe the organization's mission or most significant activities: to provide open source software to the public that we sponsor free of charge 2 Check this box if the organization discontinued its operations or disposed of more than 25% of its net assets.
    [Show full text]
  • Apache Harmony Project Tim Ellison Geir Magnusson Jr
    The Apache Harmony Project Tim Ellison Geir Magnusson Jr. Apache Harmony Project http://harmony.apache.org TS-7820 2007 JavaOneSM Conference | Session TS-7820 | Goal of This Talk In the next 45 minutes you will... Learn about the motivations, current status, and future plans of the Apache Harmony project 2007 JavaOneSM Conference | Session TS-7820 | 2 Agenda Project History Development Model Modularity VM Interface How Are We Doing? Relevance in the Age of OpenJDK Summary 2007 JavaOneSM Conference | Session TS-7820 | 3 Agenda Project History Development Model Modularity VM Interface How Are We Doing? Relevance in the Age of OpenJDK Summary 2007 JavaOneSM Conference | Session TS-7820 | 4 Apache Harmony In the Beginning May 2005—founded in the Apache Incubator Primary Goals 1. Compatible, independent implementation of Java™ Platform, Standard Edition (Java SE platform) under the Apache License 2. Community-developed, modular architecture allowing sharing and independent innovation 3. Protect IP rights of ecosystem 2007 JavaOneSM Conference | Session TS-7820 | 5 Apache Harmony Early history: 2005 Broad community discussion • Technical issues • Legal and IP issues • Project governance issues Goal: Consolidation and Consensus 2007 JavaOneSM Conference | Session TS-7820 | 6 Early History Early history: 2005/2006 Initial Code Contributions • Three Virtual machines ● JCHEVM, BootVM, DRLVM • Class Libraries ● Core classes, VM interface, test cases ● Security, beans, regex, Swing, AWT ● RMI and math 2007 JavaOneSM Conference | Session TS-7820 |
    [Show full text]
  • A Post-Apocalyptic Sun.Misc.Unsafe World
    A Post-Apocalyptic sun.misc.Unsafe World http://www.superbwallpapers.com/fantasy/post-apocalyptic-tower-bridge-london-26546/ Chris Engelbert Twitter: @noctarius2k Jatumba! 2014, 2015, 2016, … Disclaimer This talk is not going to be negative! Disclaimer But certain things are highly speculative and APIs or ideas might change by tomorrow! sun.misc.Scissors http://www.underwhelmedcomic.com/wp-content/uploads/2012/03/runningdude.jpg sun.misc.Unsafe - What you (don’t) know sun.misc.Unsafe - What you (don’t) know • Internal class (sun.misc Package) sun.misc.Unsafe - What you (don’t) know • Internal class (sun.misc Package) sun.misc.Unsafe - What you (don’t) know • Internal class (sun.misc Package) • Used inside the JVM / JRE sun.misc.Unsafe - What you (don’t) know • Internal class (sun.misc Package) • Used inside the JVM / JRE // Unsafe mechanics private static final sun.misc.Unsafe U; private static final long QBASE; private static final long QLOCK; private static final int ABASE; private static final int ASHIFT; static { try { U = sun.misc.Unsafe.getUnsafe(); Class<?> k = WorkQueue.class; Class<?> ak = ForkJoinTask[].class; example: QBASE = U.objectFieldOffset (k.getDeclaredField("base")); java.util.concurrent.ForkJoinPool QLOCK = U.objectFieldOffset (k.getDeclaredField("qlock")); ABASE = U.arrayBaseOffset(ak); int scale = U.arrayIndexScale(ak); if ((scale & (scale - 1)) != 0) throw new Error("data type scale not a power of two"); ASHIFT = 31 - Integer.numberOfLeadingZeros(scale); } catch (Exception e) { throw new Error(e); } } } sun.misc.Unsafe
    [Show full text]
  • Openjdk – the Future of Open Source Java on GNU/Linux
    OpenJDK – The Future of Open Source Java on GNU/Linux Dalibor Topić Java F/OSS Ambassador Blog aggregated on http://planetjdk.org Java Implementations Become Open Source Java ME, Java SE, and Java EE 2 Why now? Maturity Java is everywhere Adoption F/OSS growing globally Innovation Faster progress through participation 3 Why GNU/Linux? Values Freedom as a core value Stack Free Software above and below the JVM Demand Increasing demand for Java integration 4 Who profits? Developers New markets, new possibilities Customers More innovations, reduced risk Sun Mindshare, anchoring Java in GNU/Linux 5 License + Classpath GPL v2 Exception • No proprietary forks (for SE, EE) • Popular & trusted • Programs can have license any license • Compatible with • Improvements GNU/Linux remain in the community • Fostering adoption • FSFs license for GNU Classpath 6 A Little Bit Of History Jun 1996: Work on gcj starts Nov 1996: Work on Kaffe starts Feb 1998: First GNU Classpath Release Mar 2000: GNU Classpath and libgcj merge Dec 2002: Eclipse runs on gcj/Classpath Oct 2003: Kaffe switches to GNU Classpath Feb 2004: First FOSDEM Java Libre track Apr 2004: Richard Stallman on the 'Java Trap' Jan 2005: OpenOffice.org runs on gcj Mai 2005: Work on Harmony starts 7 Sun & Open Source Java RIs Juni 2005: Java EE RI Glassfish goes Open Source Mai 2006: First Glassfish release Mai 2006: Java announced to go Open Source November 2006: Java ME RI PhoneME goes Open Source November 2006: Java SE RI Hotspot und Javac go Open Source Mai 2007: The rest of Java SE follows suit 8 Status: JavaOne, Mai 2007 OpenJDK can be fully built from source, 'mostly' Open Source 25,169 Source code files 894 (4%) Binary files (“plugs”) 1,885 (8%) Open Source, though not GPLv2 The rest is GPLv2 (+ CP exception) Sun couldn't release the 4% back then as free software.
    [Show full text]
  • Free Java Developer Room
    Room: AW1.121 Free Java Developer Room Saturday 2008-02-23 14:00-15:00 Welcome to the Free Java Meeting Welcome and introduction to the projects, people and themes that make Rich Sands – Mark Reinhold – Mark up the Free Java Meeting at Fosdem. ~ GNU Classpath ~ OpenJDK Wielaard – Tom Marble 15:00-16:00 Mobile Java Take your freedom to the max! Make your Free Java mobile. Christian Thalinger - Guillaume ~ CACAO Embedded ~ PhoneME ~ Midpath Legris - Ray Gans 16:00-16:40 Women in Java Technology Female programmers are rare. Female Java programmers are even more Clara Ko - Linda van der Pal rare. ~ Duchess, Ladies in Java Break 17:00-17:30 Hacking OpenJDK & Friends Hear about directions in hacking Free Java from the front lines. Roman Kennke - Andrew Hughes ~ OpenJDK ~ BrandWeg ~ IcePick 17:30-19:00 VM Rumble, Porting and Architectures Dalibor Topic - Robert Lougher - There are lots of runtimes able to execute your java byte code. But which Peter Kessler - Ian Rogers - one is the best, coolest, smartest, easiest portable or just simply the most fun? ~ Kaffe ~ JamVM ~ HotSpot ~ JikesRVM ~ CACAO ~ ikvm ~ Zero- Christian Thalinger - Jeroen Frijters assembler Port ~ Mika - Gary Benson - Chris Gray Sunday 2008-02-24 9:00-10:00 Distro Rumble So which GNU/Linux distribution integrates java packages best? Find out Petteri Raty - Tom Fitzsimmons - during this distro shootout! ~ Gentoo ~ Fedora ~ Debian ~ Ubuntu Matthias Klose 10:00-11:30 The Free Java Factory OpenJDK and IcedTea, how are they made and how do you test them? David Herron - Lillian Angel - Tom ~ OpenJDK ~ IcedTea Fitzsimmons 11:30-13:00 JIT Session: Discussion Topics Dynamically Loaded Want to hear about -- or talk about -- something the Free Java world and don't see a topic on the agenda? This time is reserved for late binding Tom Marble discussion.
    [Show full text]
  • Maven by Example I
    Maven by Example i Maven by Example Ed. 0.7 Maven by Example ii Contents 1 Introducing Apache Maven1 1.1 Maven. What is it?....................................1 1.2 Convention Over Configuration...............................2 1.3 A Common Interface....................................3 1.4 Universal Reuse through Maven Plugins..........................3 1.5 Conceptual Model of a “Project”..............................4 1.6 Is Maven an alternative to XYZ?..............................5 1.7 Comparing Maven with Ant................................6 2 Installing Maven 10 2.1 Verify your Java Installation................................ 10 2.2 Downloading Maven.................................... 11 2.3 Installing Maven...................................... 11 Maven by Example iii 2.3.1 Installing Maven on Linux, BSD and Mac OS X................. 11 2.3.2 Installing Maven on Microsoft Windows...................... 12 2.3.2.1 Setting Environment Variables..................... 12 2.4 Testing a Maven Installation................................ 13 2.5 Maven Installation Details................................. 13 2.5.1 User-Specific Configuration and Repository.................... 14 2.5.2 Upgrading a Maven Installation.......................... 15 2.6 Uninstalling Maven..................................... 15 2.7 Getting Help with Maven.................................. 15 2.8 About the Apache Software License............................ 16 3 A Simple Maven Project 17 3.1 Introduction......................................... 17 3.1.1 Downloading
    [Show full text]
  • Java Standards: the Mandate for Interoperability and Compatibility
    metagroup.com • 800-945-META [6382] February 2005 Java Standards: The Mandate for Interoperability and Compatibility A META Group White Paper Java Standards: The Mandate for Interoperability and Compatibility Contents Executive Overview ............................................................................................. 2 Java Technology’s Value Proposition ............................................................... 2 The Java Community Process............................................................................ 4 A Customer Perspective ..................................................................................... 7 Bottom Line.......................................................................................................... 8 208 Harbor Drive • Stamford, CT 06902 • (203) 973-6700 • Fax (203) 359-8066 • metagroup.com Copyright © 2005 META Group, Inc. All rights reserved. 1 Java Standards: The Mandate for Interoperability and Compatibility Executive Overview The promise of Java technology is encapsulated in its early catch phrase, “Write once, run anywhere.” This has been a difficult promise to achieve, but META Group research finds that organizations using Java technology are seeking to benefit from platform independence and interoperability as well as avoid vendor lock-in. Having applications run unchanged on multiple platforms may be an impossible goal, yet a significant challenge is also presented by vendors “extending” published specifications to achieve competitive advantage. Although these extensions
    [Show full text]
  • Design and Analysis of a Scala Benchmark Suite for the Java Virtual Machine
    Design and Analysis of a Scala Benchmark Suite for the Java Virtual Machine Entwurf und Analyse einer Scala Benchmark Suite für die Java Virtual Machine Zur Erlangung des akademischen Grades Doktor-Ingenieur (Dr.-Ing.) genehmigte Dissertation von Diplom-Mathematiker Andreas Sewe aus Twistringen, Deutschland April 2013 — Darmstadt — D 17 Fachbereich Informatik Fachgebiet Softwaretechnik Design and Analysis of a Scala Benchmark Suite for the Java Virtual Machine Entwurf und Analyse einer Scala Benchmark Suite für die Java Virtual Machine Genehmigte Dissertation von Diplom-Mathematiker Andreas Sewe aus Twistrin- gen, Deutschland 1. Gutachten: Prof. Dr.-Ing. Ermira Mezini 2. Gutachten: Prof. Richard E. Jones Tag der Einreichung: 17. August 2012 Tag der Prüfung: 29. Oktober 2012 Darmstadt — D 17 For Bettina Academic Résumé November 2007 – October 2012 Doctoral studies at the chair of Prof. Dr.-Ing. Er- mira Mezini, Fachgebiet Softwaretechnik, Fachbereich Informatik, Techni- sche Universität Darmstadt October 2001 – October 2007 Studies in mathematics with a special focus on com- puter science (Mathematik mit Schwerpunkt Informatik) at Technische Uni- versität Darmstadt, finishing with a degree of Diplom-Mathematiker (Dipl.- Math.) iii Acknowledgements First and foremost, I would like to thank Mira Mezini, my thesis supervisor, for pro- viding me with the opportunity and freedom to pursue my research, as condensed into the thesis you now hold in your hands. Her experience and her insights did much to improve my research as did her invaluable ability to ask the right questions at the right time. I would also like to thank Richard Jones for taking the time to act as secondary reviewer of this thesis.
    [Show full text]
  • A Hardware Abstraction Layer in Java
    A Hardware Abstraction Layer in Java MARTIN SCHOEBERL Vienna University of Technology, Austria STEPHAN KORSHOLM Aalborg University, Denmark TOMAS KALIBERA Purdue University, USA and ANDERS P. RAVN Aalborg University, Denmark Embedded systems use specialized I/O devices to interact with their environment, and since they have to be de- pendable, it is attractive to use a modern, type-safe programming language like Java to develop programs for them. However, standard Java, as a platform independent language, delegates access to I/O devices, direct mem- ory access and interrupt handling to some underlying operating system or kernel, but in the embedded systems domain resources are scarce and a Java virtual machine (JVM) without an underlying middleware is an attractive architecture. The contribution of this paper is a proposal for Java packages with hardware objects and interrupt handlers that interfaces to such a JVM. We provide implementations of the proposal directly in hardware, directly as extensions of standard interpreters, and finally with an operating system middleware. The latter solution is mainly seen as a migration path allowing Java programs to coexist with legacy system components. An important aspect of the proposal is that it is compatible with the Real-Time Specification for Java (RTSJ). Categories and Subject Descriptors: D.4.7 [Operating Systems]: Organization and Design—Real-time sys- tems and embedded systems; D.3.3 [Programming Languages]: Language Classifications—Object-oriented languages; D.3.3 [Programming Languages]: Language Constructs and Features—Input/output General Terms: Languages, Design, Implementation Additional Key Words and Phrases: Device driver, embedded system, Java, Java virtual machine 1.
    [Show full text]