background preloader

Canadian Mind Products Java & Internet Glossary

Canadian Mind Products Java & Internet Glossary

Dev : Extensions : Example Code : Calling Java from Javascript From MozillaZine Knowledge Base This page is currently notes of what I had to do to call Java from Javascript from Thunderbird. Here's an example from a blog: var cl = new Packages.java.net.URLClassLoader( [ new Packages.java.net.URL( ' ] ); var aClass = Packages.java.lang.Class.forName("HelloWorld", true, cl); var aStaticMethod = aClass.getMethod("getGreeting", []); var greeting = aStaticMethod.invoke(null, []); alert(greeting); In order to write to the file system, I had to add this to the javascript code: java.lang.System.setSecurityManager(null); I could read a jar from the filesystem without a problem. Calling showJavaConsole is very useful for debugging: var jvm = Components.classes["@mozilla.org/oji/jvm-mgr;1"].getService(Components.interfaces.nsIJVMManager); jvm.showJavaConsole(); Here's the code I use to log exceptions. function logExc(e) { try { while(e !

J2J development tool J2J - Java to JavaScript integration ver. 1.5 What is this for ? It is a development tool lets you integrate Java classes and JavaScript within your HTML pages. 1. <html> Our form:<br> <form> <input type="text" name="textField"><br> <input type="button" value="Click" onClick="updateField();"> </form> <script> function updateField() { document.forms[0].textField.value=java.dbConnection.getData('some_SQL_expr'); } </script> </html> So when user clicks on the button we can call method getData from the class dbConnection and use results in our JavaScript application. Suppose you are going to use browser's DOM and need to update some part of your page. <html> <p> current paragraph text </p> <script> function changeParagraph() { pp=document.all.tags("p"); pp(0).innerText=java.myClass.myFunc('give me new text, please'); } </script> </html> So you can replace text within the paragraph with the result of some Java call. That is a main idea. How does it work ? J2J is a Java servlet. you can use: 1.

Why every Java field should have been final by default. « Javarizon Introduction Note to clarify the post: by default I mean having to write something like ‘var’ to have the current behavior (fields can be reassigned), so that if you write nothing the field is automatically final. You still have the choice about being able to reassign or not by using some kind of keyword like ‘var’. I hope it is clearer now ! We all like freedom, but what is freedom when we talk about code ? You have a lot of freedom with mutable fields, too much, why not let the compiler help you by telling it that your data is immutable ? You sure do not want to, and please do not tell me the final keywords make your code hard to read, it does the exact opposite: it tells the compiler and the reader that your data will never change and this is important information. (Note: this post is NOT about the ‘other’ final keyword, the one used on classes and methods. Examples that illustrate why every Java field should have been final by default: Example 1: Bad initialization in constructors.

Java Programming Cheatsheet This appendix summarizes the most commonly-used Java language features in the textbook. Here are the APIs of the most common libraries. Hello, World. Editing, compiling, and executing. Built-in data types. Declaration and assignment statements. Integers. Floating-point numbers. Booleans. Comparison operators. Printing. Parsing command-line arguments. Math library. The full java.lang.Math API. Java library calls. Type conversion. Anatomy of an if statement. If and if-else statements. Nested if-else statement. Anatomy of a while loop. Anatomy of a for loop. Loops. Break statement. Do-while loop. Switch statement. Arrays. Inline array initialization. Typical array-processing code. Two-dimensional arrays. Inline initialization. Our standard output library. The full StdOut API. Our standard input library. The full StdIn API. Our standard drawing library. The full StdDraw API. Our standard audio library. The full StdAudio API. Command line. Redirection and piping. Functions. Libraries of functions. Our standard random library.

Learn Java by Examples - How do I create Hibernate's SessionFactory? When creating an application the use Hibernate to manage our application persistence object we’ll need a SessionFactory. This factory creates or open a session to talk to a database. To create a SessionFactory we can define the configuration in hibernate.properties, hibernate.cfg.xml or create it programatically. In this example we’ll use the hibernate.cfg.xml configuration file, which is mostly use when creating Hibernate application. Below is our session configuration files. <? Now we have the configuration file done, let’s create a helper class that will configure and build the SessionFactory object. package org.kodejava.example.hibernate.app; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class SessionFactoryHelper { private static final SessionFactory sessionFactory; static { try { // // Build a SessionFactory object from session-factory configuration // defined in the hibernate.cfg.xml file. About Wayan Saryada

Java programming test, hands-on skills - BetterProgrammer.com UCDetector Holo Everywhere [This post is by Adam Powell, an Android Framework engineer who cares about style. —Tim Bray] Android 4.0 showcases the Holo theme family, further refined since its debut in Android 3.0. But as most developers know, a new system theme for some Android devices isn’t a new or uncommon event. For developers new system themes mean more design targets for their apps. Using system themes means developers can take advantage of a user’s existing expectations and it can save a lot of production time, but only if an app designer can reliably predict the results. Theme.Holo If you’re not already familiar with Android’s style and theme system, you should read Styles and Themes before continuing. Compatibility Standard In Android 4.0, Holo is different. This standardization goes for all of the public Holo widget styles as well. The Holo theme family in Android 4.0 consists of the themes Theme.Holo, Theme.Holo.Light, and Theme.Holo.Light.DarkActionBar. What about device themes? Theme.Holo.Light

The Underhanded C Contest Learn to code, get a job Young programmers work at an IT company in Romania, where thousands of college graduates enter the tech field yearly. Douglas Rushkoff: Americans should be learning computer code the way we learn mathLearning to code teaches us what programs do, how they're used on us, he says A free Web-based interactive tutorial makes it possibleRushkoff: Programmers in demand; employers hire code-savvy workers from abroad Editor's note: Douglas Rushkoff, who writes regularly for CNN.com, is a media theorist and the author of "Program or Be Programmed: Ten Commands for a Digital Age" and "Life Inc: How Corporatism Conquered the World and How We Can Take it Back." (CNN) -- This week, New York's Mayor Michael Bloomberg tweeted his intent to learn computer code by the end of the year. He joined about 300,000 other people who have signed up at CodeYear to receive free interactive programming lessons each week from the Codecademy, a web-based tutorial. I am greatly relieved. Douglas Rushkoff

Crash course: Embedded programming with Arduino December 20, 2011, 8:00 AM — Demand for embedded programming is growing like crazy, so anyone looking for some job security might consider becoming an ace embedded programmer. It helps to have some programming experience, but even raw beginners can get started inexpensively and learn on their own. One of the friendliest introductions to embedded coding is Arduino. Singing snowman I'm going to take my old plastic snowman (figure 1) and outfit him to sing holiday songs whenever anyone approaches within a few feet, and to blink some festive red and green LEDs. SolderingReading simple schematicsLoading and modifying Arduino programs Figure 1: Plastic snowman before his operation, mute and unlit Source: Carla Schroder Prerequisites The Singing Snowman is modeled on the Halloween Pumpkin project. Here is a handy hardware list. Ladyada's Electronics Toolkit, $100.

Related: