Java Archives | CodeGuru https://www.codeguru.com/java/ Fri, 08 Oct 2021 19:27:57 +0000 en-US hourly 1 https://wordpress.org/?v=6.3.2 Top Five Most Popular Front-end Frameworks https://www.codeguru.com/java/top-five-most-popular-front-end-frameworks/ Mon, 05 Mar 2018 08:15:00 +0000 https://www.codeguru.com/uncategorized/top-five-most-popular-front-end-frameworks/ Introduction JavaScript is the most trending and popular language among developers as a front-end framework. JavaScript-based, client-side frameworks are usually used to design interactive Web sites because they help programmers design behavior of the Web sites. During the initial days of Web development, JavaScript was used to design beautiful interfaces, add functionalities to Web apps, […]

The post Top Five Most Popular Front-end Frameworks appeared first on CodeGuru.

]]>
Introduction

JavaScript is the most trending and popular language among developers as a front-end framework. JavaScript-based, client-side frameworks are usually used to design interactive Web sites because they help programmers design behavior of the Web sites. During the initial days of Web development, JavaScript was used to design beautiful interfaces, add functionalities to Web apps, and to modify Web pages in real time. Now, JavaScript is used on the server side, Web server, and database functionalities as well. Client-side JavaScript frameworks are used to submit data to the server, apply animation effects to page elements, validate user inputs, transmit user behavior on the Web site, and create interactive contents.

In this article, I will explain the present top five most popular front-end frameworks: Angular, React, Backbone, Ember, and Vue.

Angular

AngularJS is a full-featured, open source, JavaScript-based front end framework developed by Google for mobile and desktop application development in MVC. It has become the most popular Web development framework for building large scale Web applications. The AngularJS framework provides a number of features that make it trivial to implement complex requirements such as data binding, routing, and animations.

Angular includes platform-agnostic functions, developed for speed and performance, incredible tooling, simple to use, and excels at building dynamic single page Web apps (SPAs) and supports the Model View Controller (MVC) programming structure.

AngularJS is part of the MEAN (mongoDB, express, AngularJS, and node) Stack; it builds powerful applications such as Gmail. The modularity and code organization of the Angular framework make it great for dividing up large-scale work with a team. Modularity also makes testing and debugging easier. Angular can handle heavy user interaction via forms. AngularJS also works well with the ASP.NET framework and C# language on the back end of a site.

React

React, or ReactJs, is a popular and powerful JavaScript-based front-end framework library maintained by Facebook, Instagram, and their developer communities. React uses server-side rendering (SSR) and provides a flexible, performance-oriented, componentized solution for MVC (Model View Controller) applications. React follows the declarative views methodology that makes the codes simple to understand and easier to debug; a developer can quite easily choose the option to add new features without rewriting the existing code. React offers a simpler programming model with better performance.

A large Web application’s user interfaces can be developed with the React framework. You also can develop mobile applications using React Native. It allows developers to write UI components in JavaScript that compile to native code for iOS and Android.

React has a big community of developers in GitHub and Stack Overflow.

Backbone

BackboneJS, a lightweight JavaScript library, was developed by Jeremy Ashkenas. It allows a person to develop and structure client- side applications that run in a Web browser. Backbone, also known as Backbone.js, is one of the earlier JS frameworks with a RESTful JSON interface which offers MVC framework abstracts data into models. It allows developing applications and the front end in a much easier way by using JavaScript functions. This framework provides various building blocks such as models, views, events, routers, and collections for assembling the client-side Web applications. It has a soft dependency with jQuery and a hard dependency with Underscore.js.

Ember

Ember is an open source JavaScript Web framework for developers to create scalable single page Web apps, desktop, and mobile applications. Apple Music is a notable example of an app built with Ember. Also, some of the most popular Web sites developed using Ember.js are LinkedIn, Microsoft, Netflix, Groupon, Vine, Yahoo, and Twitch. Some of the most important features that make Ember.js stand out from the rest are Ember CLI, Routing, Templating engine, data layer, and Ember inspector. This framework allows developers to use future JavaScript standards. Ember provides a command line interface utility to integrate Ember patterns into the development process and focus easily on a developer’s productivity. Ember.js provides an Inspector tool for debugging Ember applications; it uses templates that help to update the model automatically, if the content of applications gets changed.

Vue

Vue, or Vue.Js, is another a popular JavaScript front-end framework for building user interfaces. Vue is capable of powering dynamic single page applications (SPA). With a basic knowledge of HTML, CSS, and JavaScript, any Web developer can use Vue to develop Web applications.

Some of the most complex features that can be implemented using Vue are to build tooling, routing, and perform state management. The Vue core library is focused on the view layer only, and is easy to pick up and integrate with other libraries or existing projects.

Conclusion

JavaScript frameworks are the most preferred when it comes to Rapid Web Application Development. Developers can focus on the previously mentioned, well-known JavaScript frameworks and set a goal to learn them in 2018. But remember, before selecting a front-end framework, consider your skill level as well as the basic requirements of the project. I am sure one of these frameworks will fit in. Happy Reading!

The post Top Five Most Popular Front-end Frameworks appeared first on CodeGuru.

]]>
DocFlex/Javadoc: Multi-Format Doclet & Rapid Doclet Development Tool https://www.codeguru.com/java/docflex-javadoc-multi-format-doclet-rapid-doclet-development-tool/ Mon, 23 Apr 2012 14:22:00 +0000 https://www.codeguru.com/uncategorized/docflex-javadoc-multi-format-doclet-rapid-doclet-development-tool/ DocFlex/Javadoc is both a multi-format Javadoc Doclet and a programming tool for rapid development of Javadoc-based Java API documentation generators in various output formats, which by their quality and complexity are equal or exceed the standard Javadoc. CONTENTS Key Features DocFlex Doclet + Template Sets Template Designer Doclet API as virtual XML document Abstract Formatting […]

The post DocFlex/Javadoc: Multi-Format Doclet & Rapid Doclet Development Tool appeared first on CodeGuru.

]]>
DocFlex/Javadoc is both a multi-format Javadoc Doclet and a programming tool for rapid development of Javadoc-based Java API documentation generators in various output formats, which by their quality and complexity are equal or exceed the standard Javadoc.

CONTENTS
Key Features
DocFlex Doclet + Template Sets
Template Designer
Doclet API as virtual XML document
Abstract Formatting Concept
Hypertext
Output Formats
Integrations
JavadocPro Template Set
Framed HTML (Classic JavaDoc)
Single File HTML
RTF Documentation
Filtering of classes/members by tags/annotations
Combined Screenshot
Editions
Full Edition
DocFlex/Doclet
Benefits of DocFlex/Javadoc
About DocFlex
Key Concepts
Other Applications
DocFlex/XML
DocFlex/XSD
DocFlex/WSDL
Links

Key Features

  • DocFlex Doclet + Template Sets

    Actual doc-generators are created in the form of special templates interpreted by the DocFlex Doclet, which is the template interpreter / output generator wrapped in the form of a Javadoc Doclet.

    See also: About DocFlex

  • Template Designer

    The high quality graphic Template Designer represents the templates in a visual form resembling the output they generate. At the same time, it allows programming of very sophisticated processing of the input data and formatting of the generated output — features that are possible to develop so far only by direct Java coding!

    The following screenshot is the JavadocPro | class.tpl template open in the Template Designer (click to see in full size):

  • Doclet API as virtual XML document

    The entire Doclet API is represented in a form of virtual XML document called Doclet DSM (here “DSM” stands for “Data Source Model”), on which the designing and processing of templates is based. This allows using some of the technologies developed around XML for Javadoc.

    Most of data mining and retrieval is based on Location Paths / Location Rules, which is a developed extension of XPath. This is complemented with the specifically adapted hash-maps (called element maps) that serve the role of indexes.

  • Abstract Formatting Concept

    The templates are designed independently on a particular output format. All formatting is specified in some universal way using properties of template components. During the generation, this is rendered with the appropriate features available in the selected output format.

    It also supports the rendering of embedded HTML, which means interpreting in non-HTML output formats (such as RTF) the HTML tags embedded in text data (e.g. documentation comments). Almost all HTML tags practically usable in doc-comments are supported.

  • Hypertext
    • Generation of cross-reference hyperlinks interconnecting the whole documentation. The hyperlinks are defined in templates in a very abstract way using special link/target keys.
    • Generation of hyperlinks to any external URLs. This allows, for instance, linking the generated JavaDoc to any other existing javadoc-generated documentation of external referenced classes.

    Hyperlinks can be generated in all output formats that support them (this currently includes HTML and RTF). In RTF, the cross-reference links can be represented also in the form of page number references, which in effect makes them usable even in printed documentation.

  • Output Formats
    • HTML (both framed multi-file and single-file HTML output)
    • RTF (version 1.6 – supported since Word 2000; can be further converted to PDF)
    • TXT (plain text)

      It may be particularly useful for various utilizations of the Java code information provided by the Doclet API (for instance, to generate XML files by it, or SQL files to import into a database).

  • Integrations

    As being a Javadoc Doclet (that is a special plug-in for Javadoc), DocFlex Doclet can be integrated with probably anything that runs Javadoc itself. We have worked out and tested the integrations with the following systems:

    Sample Ant buildfile and Maven POM file are included in the distributed software archive.

  • JavadocPro Template Set

     

    Since version 1.6.0, DocFlex/Javadoc is supplied with a new “JavadocPro” template set. Using it you can generate:

    • Framed HTML JavaDoc identical to classic one (click on a screenshot to view a demo HTML JavaDoc):

       

    • Single-file HTML JavaDoc with basic content (project overview, package summaries, class details):

       

    • The newly redesigned RTF JavaDoc (click on a screenshot to see in full size):

       

      The RTF can be further converted to PDF.

    • Full Edition (or “DocFlex/Javadoc” as it is) includes all features available in this software:
      1. Template Designer – provides a GUI to design/modify templates.
      2. DocFlex Doclet – the template interpreter / output generator wrapped in the form of a Javadoc Doclet.
      3. JavadocPro Template Set – the new advanced template set able to generate classic HTML JavaDoc as well as redesigned RTF documentation with a possibility to exclude classes/members by tags/annotations.
      4. Basic Template Set – an early version of standard template set.

      Everything is covered by the same “DocFlex/Javadoc” license, which unlocks all implemented functionality.

    • DocFlex/Doclet is a free edition of DocFlex/Javadoc. It does not include the Template Designer (that is, you cannot create/modify any templates). What it includes is:
      1. DocFlex Doclet
      2. JavadocPro Template Set
      3. Basic Template Set

      The “DocFlex/Doclet” is covered by the Free License. That means you can use it immediately as soon as you download it. No registration required! The output (JavaDoc) you generate with it is free for any usage.

      JavadocPro will work in limited mode. However, that will be enough to generate full-blown framed HTML JavaDoc with the same functionality as provided by the standard Javadoc.

      If you are not a big fan of the new JavaDoc design introduced in Java 7, you can use JavadocPro templates to generate the classic-looking JavaDoc under Java 7 too. That’s free!

       

    Benefits of DocFlex/Javadoc

    • Generation of classic JavaDoc with a possibility to exclude any classes and members by tags/annotations.

      The standard Javadoc does not support this and unlikely to ever support it. That’s because such a feature is pretty much controversial:

      1. It is rather difficult to implement. To make the generated docs consistent, the excluded classes must be not only be removed, everything needs to be changed as if those classes never existed at all. For instance, the public members of some excluded classes may still be required to appear in the documentation. But in that case they must be shown as if they are defined in other classes, which actually inherit them.
      2. It contradicts the very essence of class/member visibility. According to the canonical approach, instead of deriving a public API directly from the implementation, you are supposed, first, to define the entire API in the form of some abstract interfaces and, then, to maintain the actual implementation separately.

      Of course, real life does not always follows some canonical schemes!

    • Generation of outstanding quality RTF JavaDoc.

      You will hardly find any other tool able to generate such a complex RTF!

    • Unlimited possibility to customize your Java API documentation.

      Since all the generated documentation output is programmed entirely in templates (which are open for any changes), now you can:

      • Translate all JavaDoc text labels into any other language.
      • Change fonts, colors and other look & feel of your JavaDoc.
      • Add more filtering conditions for what is included in your JavaDoc.
      • Add sections with some special content (not found in the classic JavaDoc).
    • Program a complete different JavaDoc generator / utilize your Java project info for whatever else.

      Ultimately, you can program a completely different JavaDoc generator, and even in a different format (particularly XML-based, e.g. DITA) using plain text output. DocFlex/Javadoc can help you also to retrieve whatever information about your Java project (if only provided by Doclet API) so as to utilize it for other purposes — not only as documentation.

    About DocFlex

    DocFlex is a technology for development of high quality template-driven documentation/report generators from any kind of data provided by various software applications via their standard Java APIs.

     

    Key Concepts

     

    It is based on four generalizations:

    1. The mapping of the entire Java API onto a virtual XML-like representation made of some elements and attributes so as to process it in a universal way using techniques borrowed from the field of XML, like XPath (or more precisely, a conceptual analogue of XPath with some extensions not present in it).
    2. The abstract formatting concept based on four layouts (flow of text, flow of paragraphs or paragraph-like objects, tables and lists), which can be rendered in most modern document formats (e.g. HTML, RTF, XSL-FO etc.)
    3. The automatic generation of hyperlinks (or their page number reference equivalents) by matching sets of keys produced from certain natural properties of the objects (entities) being documented and hyper-linked.
    4. The representation of the entire object controlling structure of an output generator (made on the first three principles) in the form of a special plain-text file called template, which can be created and edited using a graphic template designer that visualizes all the controlling objects (now becoming template components) in a form resembling the output they produce.

       

      Since the template themselves are not true computer programs, something needs them to interpret. That is called the template interpreter / output generator.

    Other Applications

     

    DocFlex/Javadoc is not the only application of DocFlex technology. Currently, there are a few others:

    • DocFlex/XML

      The template-driven documentation/report generator by any data stored in XML files. More precisely, it is a development tool (SDK) and a runtime environment (RE) for such generators, the same as DocFlex/Javadoc is for Javadoc doclets.

      DocFlex/XML home page: http://www.filigris.com/products/docflex_xml/

    • DocFlex/XSD

      The template-driven documentation generator for W3C XML schemas (XSD files) — probably, the best in the world! In fact, it is nothing more than the following three things:

      1. DocFlex/XML — see above.
      2. DocFlex/XML XSDDoc — a template set for DocFlex/XML that implements a high quality XML schema documentation generator.
      3. DocFlex/XML XMLSpy Integration — an integration of DocFlex/XML with Altova XMLSpy®. It allows automatic insertion of XSD diagrams produced by XMLSpy into the XML schema documentation generated by DocFlex/XML XSDDoc. The entire thing (DocFlex/XML + XSDDoc + XMLSpy) works as a single documentation generator. (More similar integrations are coming).

      DocFlex/XSD home page: http://www.filigris.com/products/docflex_xsd/

    • DocFlex/WSDL

      A similarly made WSDL documentation generator, which is in development yet. It is coming in a few months. Its home page will be here: http://www.filigris.com/products/docflex_wsdl/

    Links

    DocFlex/Javadoc home page: http://www.filigris.com/products/docflex_javadoc/
    DocFlex/Javadoc examples: http://www.filigris.com/products/docflex_javadoc/examples/
    Free downloads: http://www.filigris.com/downloads/
    An extended version of this article can be found at: http://www.filigris.com/ann/docflex_javadoc_v1.6.0/
    It is also available as zip archive (with all images): http://www.filigris.com/ann/docflex_javadoc_v1.6.0.zip

    The post DocFlex/Javadoc: Multi-Format Doclet & Rapid Doclet Development Tool appeared first on CodeGuru.

    ]]> Top Down with Memorization Complexity https://www.codeguru.com/java/top-down-with-memorization-complexity/ Fri, 24 Feb 2012 19:10:57 +0000 https://www.codeguru.com/uncategorized/top-down-with-memorization-complexity/ The purpose of this article is to analyze the complexity of algorithms written using a top down approach. Most of the problems can inherently be described using top down recursion. The complexity of an algorithm, however, makes it far from usable in practical scenarios. This kind of algorithm shows exponential complexity and might need some […]

    The post Top Down with Memorization Complexity appeared first on CodeGuru.

    ]]>
    The purpose of this article is to analyze the complexity of algorithms written using a top down approach.

    Most of the problems can inherently be described using top down recursion. The complexity of an algorithm, however, makes it far from usable in practical scenarios. This kind of algorithm shows exponential complexity and might need some kind of specialized solution to bring the hardness of the solution from exponential to polynomial complexity. To describe one such case, let’s take the example of one moderate problem. The problem is as described below and is another variation of well known LCS (Longest common subsequence problem). The purpose of taking a problem with moderate complexity is to provide the audience with a challenge to come to a conclusion and work out a solution that is close enough for practical use. The problem is also different from what most of the readers have seen elsewhere. The problem is as given below.

    A subsequence is palindromic if it is the same whether read left to right or right to left. For
    Instance, the sequence
    A;C; G; T; G; T;C; A; A; A; A; T;C;G has many palindromic subsequences, including A;C; G;C;A and A; A; A;A (on the other hand, the subsequence A;C; T is not palindromic). Devise an algorithm that takes a sequence x[1 : : : n] and returns the (length of the) longest palindromic subsequence. Its running time should be O(n2).

    So as a layman programmer the problem seems to be recursive and solved with some recursive scheme.
    Let’s call the Longest Palindrome Sequence as LPS. So given a string Aij, the solution is below.

                                 Ai = Aj   --o  2 + LPS(i+1, j-1)
    LPS(i, j) = Max
                                Ai != Aj   --o  Max(LPS(i, j-1), LPS( i+1, j))
    

    The algorithm can easily be reproduced in any available language which supports recursion.

    So our naC/ve algorithm looks like

                       int LPS(i, j) {
                                  If (Ai == Aj) {
                                        return 2 + LPS(i+1, j-1);
                                  } else {
                                        return Max(LPS(i, j-1), LPS( i+1, j));
                                  }
                       }

    The solution by far looks correct. But can it be used practically for any good use? The exponential complexity of the above algorithm might even make it difficult for strings of moderate lengths. If we look closely at the solution we see the depth of the recursion increases exponentially. So given string of length k, the complexity of the above algorithm is 2 ^ k, since every problem is divided into 2 new problems.
    Worse, the same problem is repeating itself. So the total complexity in the worst case, when there is no palindrome in the problem string, is (2* 2 ^ K).

    To make it more clear consider substring I, j. The problem I +1, j and I, j-1 has I + 1, j -1 common problems. Is there a way to avoid processing the same problems? Can we make use of computations, which we have already done? A minute’s reflection will tell yes we could.

    Below shows how we could do this. Read M as matrix in below code of length I, j.

                       int LPS(i, j) {
                            int lcs;
                            If (M[i][j] == -1) {
                                  If (Ai == Aj) {
                                        lcs =  2 + LPS(i+1, j-1);
                                  } else {
                                        lcs = return Max(LPS(i, j-1), LPS( i+1, j));
                                  }
                                  M[i][j] = lcs;
                            }
                            Return M[i][j];
                       }
    

    The above algorithm is memoization and reduces the complexity of the problem by half. The above solution skips computing similar problems.

    There is yet another solution to the above problem, which reduces the complexity to polynomial time.
    As most of us know it’s a bottom up approach using Dynamic Programming.

    The solution is given below and self explanatory. M is matrix where we store results for previous computations.

    F           Mk,I   o   Ak  != Ai o    Mk,i-1
         i = 0, n                           Ak  =  Ai o   2 + Mk+1, i-1
         j = 0, i
         k = j, i
    

    Read F as for each. For the above algorithm the complexity is n ^ 3. The table is constructed bottom up. For ex A0, A0..Aj, A0 – An. So if you know Mi, j-1 you know M I, j.
    Do we need more explanation to code above thing? I guess not.

    The complexity can further be reduced to n ^ 2 if we reverse the same string and run LCS over the two strings. Since complexity of LCS (Largest common ancestor is n ^ 2).

    The post Top Down with Memorization Complexity appeared first on CodeGuru.

    ]]>
    Building and Using the Secret Service Java API https://www.codeguru.com/java/building-and-using-the-secret-service-java-api/ Tue, 21 Feb 2012 18:27:06 +0000 https://www.codeguru.com/uncategorized/building-and-using-the-secret-service-java-api/ The Secret Service API was jointly designed by the Gnome keyring and the KDE KWallet developers in order to have a standard way for desktop applications to access and manage stored passwords in both Gnome and KDE environments. In this article I will show you how to generate java code for the Secret Service API […]

    The post Building and Using the Secret Service Java API appeared first on CodeGuru.

    ]]>
    The Secret Service API was jointly designed by the Gnome keyring and the KDE KWallet developers in order to have a standard way for desktop applications to access and manage stored passwords in both Gnome and KDE environments.

    In this article I will show you how to generate java code for the Secret Service API and then use it in your Java application.

    A Bit of Terminology

    If you are a Gnome user, passwords and keys are stored and managed by the GNOME Keyring Manager. The GUI to access passwords is a program called Seahorse.
    In gnome-keyring, passwords and keys are stored in keyrings. For example the keyring that contains all passwords and keys that you will be able to use
    after logging into your Gnome environment is called ‘login’.

    In the KDE environment the application is called KWallet. Passwords and keys are stored in a so-called ‘Folder’.
    The Secret Service API is implemented from KDE-4.8 in the KSecretService module used by KWallet.

    In the Secret Service API terminology, passwords and keys are called ‘Items’. Keyrings and folders are called ‘Collections’

    Mapping between SecretService API and desktop terminology
    Secret Service API collection item
    Gnome keyring user/password;key
    KDE folder user/password;key

    Use cases in this article were designed for the Gnome environment. They are of course aimed to work under the KDE 4.8 environment.

    The post Building and Using the Secret Service Java API appeared first on CodeGuru.

    ]]>
    All About Exception Handling in Java https://www.codeguru.com/java/all-about-exception-handling-in-java/ Fri, 20 Jan 2012 17:13:21 +0000 https://www.codeguru.com/uncategorized/all-about-exception-handling-in-java/ Exception Handling in Java is just the same as it is in real life. Let’s say you are driving from Princeton to New York. 1.How would you handle the case where in your car meets with an accident. 2.Can you do anything to avoid break failure. 3.Can you do anything if an earth quake occurs […]

    The post All About Exception Handling in Java appeared first on CodeGuru.

    ]]>
    Exception Handling in Java is just the same as it is in real life. Let’s say you are driving from Princeton to New York.

    1.How would you handle the case where in your car meets with an accident.
    2.Can you do anything to avoid break failure.
    3.Can you do anything if an earth quake occurs on your way to New York ?

    These are the three kinds of situation you come across in any program.

    Exception handling in Java
    Exception handling in Java

    So, How do we handle exceptions ? How do you program your code with good exception handling ? This is the question that comes to any one’s mind who has just learned OOPS concepts in Java and is looking to learn more.

    Exceptions are kind of thrown when they occur. If you catch them and and do something about it, the program continues smoothly with what it was doing. If you don’t catch them, the program breaks and stops and you see red lines in the output. So, why would you not catch any exception ? Why would you allow it to break and stop a program. The reason is that there are kinds of exceptions that you are not supposed to catch. Confusing, right ? Read on….

    There are two types of exceptions: Checked Exception and Unchecked Exception. In other words, Compile time Exception and Runtime Exception. Yes, I am giving the other terminology because otherwise you will tell me that you have heard of them and what they are. There is double terminology for almost everything in Java. This makes Java look difficult, when it’s not. You might still be feeling that Java is difficult, but never mind; let’s continue on with Exception handling, so that I can show you that Exception Handling is easy.

    Checked and Unchecked Exceptions

    The only two types of exceptions in Java are Checked and Unchecked. There is a class in Java called Exception, whose parent class(super class) is called Throwable. Throwable has two children, Exception and Error. Both Exceptions and Errors can be thrown literally. This is because they are children of Throwable and inherit that quality from it. We will talk about Errors later. We will continue on with Exceptions. Class Exception has a lot of children classes(subclass).

    Exceptions are of two types, Checked and Unchecked Exception. So, how do you know which are checked and which are unchecked? Class Exception has a child class called Runtime Exception. All its children and their children and so on… are Unchecked Exceptions. All the brothers/sisters of Runtime Exception and their families under them are Checked Exceptions. In other words, all the children(and families under them) of Exception class, except Runtime Exception, are Checked Exceptions. They are called Checked because compiler checks for them and forces you to decide on weather you want to catch and handle it or not (allow it to break and stop your program).

    Example FileNotFoundException. Unchecked exceptions should never happen if handled, so the compiler does not force you to decide on its handling. If you find an unchecked exception during testing you are supposed to fix your program so that an unchecked exception never occurs. For example, the NullPointerException is like break failure. So when you find that the break has failed during testing, go and fix it. You don’t handle a break failure when it happens while running the Car. It should be fixed when found, so that it never happens upon driving.

    Errors are like an earthquake; they happen due to a problem in JVM or the physical machine. If they occur, they occur. You cannot do anything about them, except report them to the JVM creator or System Administrator.

    Exception Handling For Checked Exceptions, the compiler will force you to do one of the two things. Either do a try catch finally or mention the throws clause at the end of the method signature. You have to fix unchecked exceptions so that they never occur. You cannot do anything about the errors; the error will be displayed on the screen when the program fails due to a JVM problem or machine problem.

    The post All About Exception Handling in Java appeared first on CodeGuru.

    ]]>
    Tomorrow’s Web Standards https://www.codeguru.com/java/tomorrows-web-standards/ Mon, 08 Aug 2011 17:10:00 +0000 https://www.codeguru.com/uncategorized/tomorrows-web-standards/ Premise I hope by the end of this article you will have a good grasp on the current draft of upcoming web standards. This includes HTML5, CSS3 and newer JavaScript updates. I’m going to assume that you are up-to-date on current web standards. If you do not know HTML5 or XHTML, CSS, or JavaScript then […]

    The post Tomorrow’s Web Standards appeared first on CodeGuru.

    ]]>
    Premise

    I hope by the end of this article you will have a good grasp on the current draft of upcoming web standards. This includes HTML5, CSS3 and newer JavaScript updates.

    I’m going to assume that you are up-to-date on current web standards. If you do not know HTML5 or XHTML, CSS, or JavaScript then this article is not for you. I suggest you come back after obtaining a basic understanding of the three.

    Also note that most links in this article will direct to w3.org or w3schools.com. Those are the two leading websites for any web based information you can find. Some other sites can provide more detail and are sometimes a bit clearer, but those two sites should be your first stop in the world of web development.

    The HTML5 Umbrella Myth

    When most people hear of our upcoming web standards, they tend to lump CSS3 and newer JavaScript solutions into HTML5 explanations. Right off the bat, I want to clarify that confusion. HTML5, CSS3, and JavaScript are three completely separate languages, but have a huge impact on each other. When the new standards are solidified, it will be impossible to build a well presented website/page without both HTML5 and CSS3 being used. If you want any user interaction at all, you will need to add JavaScript. Although JavaScript has been around a while, new methods and events are being created to interact with the new elements and properties.

    Official Start Date of the New Web Standards?

    While not yet accepted in final draft, HTML5 and CSS3 are supported to a good extend in most modern web browsers. The biggest exception to this is Microsoft’s Internet Explorer. They are usually two years behind in accepting most W3 standards. And even when the newest standards are accepted, there’s no law stating that browsers must implement every aspect. Until then, you can always start building web solutions for browsers that already support the greatly needed modifications. Here’s a rather comprehensive list.

    HTML5 & CSS3 Support

    The post Tomorrow’s Web Standards appeared first on CodeGuru.

    ]]>
    Easy way to set up global API hooks https://www.codeguru.com/java/easy-way-to-set-up-global-api-hooks/ Wed, 10 Mar 2010 19:44:33 +0000 https://www.codeguru.com/uncategorized/easy-way-to-set-up-global-api-hooks/ Written by: Sergey Podobriy, Development Coordinator of Driver Development Team, Apriorit Inc. http://www.apriorit.com Contents 1.1. What is API hooking? 1.2. Local and global hooks 2. AppInit_DLLs infrastructure 3. Mhook library 4. Writing the code 4.1.Original function 4.2.Hooked function 4.3.Setting the hook 4.4.Unhooking 5.Running a sample 6.Limitations 7.Useful references   1.1 What is API hooking? API […]

    The post Easy way to set up global API hooks appeared first on CodeGuru.

    ]]>
    Written by:
    Sergey Podobriy,
    Development Coordinator of Driver Development Team, Apriorit Inc.
    http://www.apriorit.com

    Contents

    1.1. What is API hooking?
    1.2. Local and global hooks
    2. AppInit_DLLs infrastructure
    3. Mhook library
    4. Writing the code
    4.1.Original function
    4.2.Hooked function
    4.3.Setting the hook
    4.4.Unhooking
    5.Running a sample
    6.Limitations
    7.Useful references

     

    1.1 What is API hooking?

    API hooking means intercepting some API function calls. By means of it you can alter the behavior of any software. Hooks are widely used by antiviruses, security applications, system utilities, programming tools etc.

    1.2 Local and global hooks

    There are two types of hooks: local and global ones. Local hooks are applied only to the specific application. Global hooks are applied to all processes in the system. The hook technique, which is shown in this article, is global and impacts on all processes in all sessions (in contrast to the SetWindowsHooks way that is bounded to the specific desktop).

    2. AppInit_DLLs infrastructure

    AppInit_DLLs infrastructure is a mechanism for loading an arbitrary list of DLLs in all user-mode processes which are linked with User32.dllB (Actually, there are very few executables that are not linked with it). The DLLs are loaded by User32.dll on its initialization.

    The behavior of the AppInit_DLLs infrastructure is configured by a set of values that are stored under the HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NT CurrentVersionWindows key in the registry. These registry values are described in the table:

    Value Description Sample values
    LoadAppInit_DLLs
    (REG_DWORD)
    Value that globally enables or disables AppInit_DLLs. 0x0 – AppInit_DLLs are disabled.
    0x1 – AppInit_DLLs are enabled.

    AppInit_DLLs
    (REG_SZ)

    Space – or comma -separated list of DLLs to load. The complete path to the DLL should be specified using short file names. C:PROGRA~1TestTest.dll
    RequireSignedAppInit_DLLs
    (REG_DWORD)
    Require code-signed DLLs. 0x0 – Load any DLLs.
    0x1 – Load only code-signed DLLs.

    Table 1 – AppInit_DLLs Infrastructure registry values.

    3. Mhook library

    There are several libraries for api hooking. The typical things that they do are:

    1. Overwriting the beginning of the target function with custom code (so-called trampoline). When the function executes it will jump to the hook handler.
    2. Storing overwritten original code of the target function somewhere. It is needed for the correct target function functioning.
    3. Restoring overwritten portion of the target function.

    Mhook is a free open source library for api hooking. It supports both x86 and x64 platforms and it is very easy in use. Mhook interface is simple and quite self describing:

      BOOL  Mhook_SetHook(PVOID *ppSystemFunction, PVOID pHookFunction);
      BOOL  Mhook_Unhook(PVOID *ppHookedFunction);
    

    For more info on library usage see the code sample shown in the next paragraph or visit Mhook home page.

    4. Writing the code

    We aregoing to write a user-mode DLL. First you should download the latest Mhook sources and add it to the project. If you are using precompiled headers turn it off for Mhook files.

    As I’ve mentioned above our example will hide the calc.exe from the list of running processes.

    4.1 Original function

    The list of running processes is queried by calling NTAPI function NtQuerySystemInformation. So, we need to add some NTAPI stuff to our project. Unfortunately winternl.h header doesn’t contain full information and we have to define required data types ourselves:

    /////////////////////////////////////////////////////////////////////////
    // Defines and typedefs
    
    #define STATUS_SUCCESS  ((NTSTATUS)0x00000000L)
    
    typedef struct _MY_SYSTEM_PROCESS_INFORMATION
    {
        ULONG                   NextEntryOffset;
        ULONG                   NumberOfThreads;
        LARGE_INTEGER           Reserved[3];
        LARGE_INTEGER           CreateTime;
        LARGE_INTEGER           UserTime;
        LARGE_INTEGER           KernelTime;
        UNICODE_STRING          ImageName;
        ULONG                   BasePriority;
        HANDLE                  ProcessId;
        HANDLE                  InheritedFromProcessId;
    } MY_SYSTEM_PROCESS_INFORMATION, *PMY_SYSTEM_PROCESS_INFORMATION;
    
    typedef NTSTATUS (WINAPI *PNT_QUERY_SYSTEM_INFORMATION)(
        __in       SYSTEM_INFORMATION_CLASS SystemInformationClass,
        __inout    PVOID SystemInformation,
        __in       ULONG SystemInformationLength,
        __out_opt  PULONG ReturnLength
        );
    

    To store original function address create a global variable and initialize it:

    //////////////////////////////////////////////////////////////////////////
    // Original function
    
    PNT_QUERY_SYSTEM_INFORMATION OriginalNtQuerySystemInformation =
        (PNT_QUERY_SYSTEM_INFORMATION)::GetProcAddress(::GetModuleHandle(L"ntdll"),
    	"NtQuerySystemInformation");
    

    The post Easy way to set up global API hooks appeared first on CodeGuru.

    ]]>
    Direct RIA: Future of RIA https://www.codeguru.com/java/direct-ria-future-of-ria/ Fri, 09 Oct 2009 15:41:55 +0000 https://www.codeguru.com/uncategorized/direct-ria-future-of-ria/ Direct RIA: Future of RIA More choices, difficult decision Though enterprises can benefit from Rich Internet applications, adopting new technologies can also introduce risk. The first problem is how to choose the right solution as it is easy to make a wrong decision because of too many choices, unclear criteria, and complex requirements. Productivity or […]

    The post Direct RIA: Future of RIA appeared first on CodeGuru.

    ]]>
    Direct RIA: Future of RIA

    More choices, difficult decision

    Though enterprises can benefit from Rich Internet applications, adopting new technologies can also introduce risk. The first problem is how to choose the right solution as it is easy to make a wrong decision because of too many choices, unclear criteria, and complex requirements.

    Productivity or Controllability

    RIA solutions can be generally classified into two categories – client centric or server-centric. Client-centric frameworks are like manually transmission car which provide more control, but requires more effort. Unlike client-centric frameworks, server-centric frameworks are like auto transmission cars which is easy, thus, they can boost developer’s productivity by making AJAX technology transparent to developers.
    But, which to choose remains a headache. Full control or productivity? Can we benefit from both of them at the same time? The best case is that they can choose either way to satisfy different requirements like manually auto-transmission car!

    Direct RIA = client+server fusion approach

    Direct RIA enables a revolutionary client+server fusion approach which attempts to leverage benefits of productivity and controllability at the same time.programming when they require full customization, or more responsiveness.

    Architecture Overview of Direct RIA

    Direct RIA is a server-centric solution plus optional client-side programming. If you take a look at the following diagram, you can see that in the server-centric programming model allow developers to build the Web application using pure server-side code. The server-side engine will generate required HTML, and JavaScript code automatically. Then, the client-side engine will interact with the DOM tree to refresh the content. Moreover, the synchronization between the browser and the server is automated by the corporation of the client-side, and server-side Ajax engines. Thus, developers can focus on the application itself instead of the complex Ajax technologies.

    However, one of the major disadvantages of pure server-centric programming model is that developers cannot fully control the presentation of user interface. To overcome this issue, Direct RIA enables an optional client-side programming model that enables developers to write client code to control the user interface directly if necessary.

    The post Direct RIA: Future of RIA appeared first on CodeGuru.

    ]]>
    TIP: Finding the Moving Average Using Prior Boundary Condition https://www.codeguru.com/java/tip-finding-the-moving-average-using-prior-boundary-condition/ Wed, 15 Jul 2009 16:53:15 +0000 https://www.codeguru.com/uncategorized/tip-finding-the-moving-average-using-prior-boundary-condition/ MovingAverage can be used to calculate average of the previous n (window_size) data points, just by providing the list of integers and the window size!

    The post TIP: Finding the Moving Average Using Prior Boundary Condition appeared first on CodeGuru.

    ]]>
    MovingAverage can be used to calculate average of the previous n (window_size) data points, just by providing the list of integers and the window size!

    The post TIP: Finding the Moving Average Using Prior Boundary Condition appeared first on CodeGuru.

    ]]>
    TIP: Convert GMT to Local Date/Time https://www.codeguru.com/java/tip-convert-gmt-to-local-date-time/ Wed, 01 Apr 2009 18:00:25 +0000 https://www.codeguru.com/uncategorized/tip-convert-gmt-to-local-date-time/ Almost all applications enable for internationalization allow you to save the datetime columns in UTC/GMT time zones as well as allow you to convert datetime to local time zones based on users time zone preferences. This project includes a SQL function dbo.get_local_datetime (datetime, time_zone) to convert GMT based datetime values in the database to local […]

    The post TIP: Convert GMT to Local Date/Time appeared first on CodeGuru.

    ]]>
    Almost all applications enable for internationalization allow you to save the datetime columns in UTC/GMT time zones as well as allow you to convert datetime to local time zones based on users time zone preferences.

    This project includes a SQL function dbo.get_local_datetime (datetime, time_zone) to convert GMT based datetime values in the database to local timezone. SQL Function relies on a table containing time zone offsets by time zone ids. This table is created and populated by timezone_offsets.sql.

    The project also includes a JAR file to generate timezone_offsets.sql the time zone offset SQL script for desired years, by default it generates information from 1995 to 2050. Source code to the JAR is also included. Just read readme.txt to get started using this.

    There are different opinions on how many time zones a business application should offer. For example, Microsoft Windows lists all of the major time zones, which is about 74 of them. While this is set as a standard by Microsoft, many applications need to support subsets of these time zones. Java covers a wide range of time zone subsets based on major cities over the globe.

    Time Zones Covered

    This table generated by timezone_offsets.sql covers 599 subsets of all the timezones supported by JDK 6.0 it also takes care of any changes made by the Energy Policy Act (EPAct) of 2005 or any other changes made in past and possibly future changes as too. You can use the jar application to generate the time zone offsets SQL script for a limited period of years or for default period. So if next java version adds 200 more sub time zones all you need to do is re-genarate this Script.

    Using the code

    All you need to do is run the script timezone_offsets.sql to your database. That’s it! You are done. You can run the run_test.sql to test the results.

    To genarate the time zone offsets SQL script, you need to invoke the JAR thru the command prompt or simply double click the JAR. To generate the script for a limited period, you might need to invoke the JAR through the command prompt and pass parameters for the startyear and endyear:

    java -jar timezoneoffset.jar 2000 2015

    How Code works

    The script generation code basically loops thru the array of time zones. It uses java.util.Calendar and java.util.TimeZone initializing the Calendar to the day from “startyear” or default 1995 incrementing day by day finding the offsets with time zone GMT and local time zone generating sql inserts as it finds differences in offsets. This goes on until it reaches “endyear”.

    The SQL function searches for the relative offset as per the input date and time zone ID and returns Local Time in the required time zone.

    # # #

    The post TIP: Convert GMT to Local Date/Time appeared first on CodeGuru.

    ]]>