-
  GAYANB.COM
  Free IT Books, Study Guides, Practice Exams, Tutorials and Software
Sunday, February 05th 2012
-  Free Books
Free computer books
Best free J2EE books
Best free .NET books
Best free XML books
Best free PHP books
Free Java books
Free J2EE books
Free JSP books
Free J2ME books
Free .NET books
Free C# books
Free ASP.NET books
Free VB.NET books
Free VS.NET books
Free Oracle books
Free Linux books
Free MySql books
More free books
Free MSDN Mags
Free Oracle Mags
Free software CDs
- Certifications
Articles
SCJA
  Exam Details
  Mock exams
  Study guides
SCJP
  Exam Details
  Mock exams
  Study guides
  Sample chapters
SCJD
  Exam Details
  Mock exams
  Study guides
SCWCD
  Exam Details
  Mock exams
  Study guides
  Sample chapters
SCBCD
  Exam Details
  Mock exams
  Study guides
  Sample chapters
SCEA
  Exam Details
  Mock exams
  Study guides
  Sample chapters
SCMAD
  Study Guides
SCDJWS
  Study Guides
MCAD/MCSD
  Mock exams
MCSE
  MCSE guides/exams
CCNA
  Exam Resources
- Java / J2EE
Articles
  Artima
  DevX
  JDJ
  JavaBoutique
  Performance
  Wireless
- .NET
Knowledge Base
Articles
  DevX
  .NET Framework
  ASP.NET
  C#
  VB.NET
  Visual Studio.NET
- About
Gayan Balasooriya

Broken links?
Suggest good links
To remove links
 weblogs from Javablogs.com

Night Dreams about NetBeans 7.1, etc.; Day Work Configuring CentOS Linux for JavaFX 2.1

Last night I dreamed seemingly all night about NetBeans 7.1, the JavaFX 2.1 Developer Preview, the JDK 6 and JDK 7 installations on my CentOS Linux system, Java threads, the JDK 7 Fork/Join framework, closures... and probably a few more things were in there too. That kind of thing happens to me sometimes after a late night of programming or development-related brainstorming.

Now, if these dreams happen when I have looming deadline, I usually consider it a nightmare -- because I'll often "work" all night "solving" some problem that doesn't exist in my day world. But I'm hoping last night's dreams will ultimately prove to have been at least a little bit productive. There were plenty of curious ideas mixed in there. I'll find out if any of it's useful over the next several days...

Day work: JavaFX 2.1 Developer Preview on Linux

It's daytime now, so I'll get down to some practical work. First, there's some good news for developers who want to try out JavaFX 2.1 Developer Preview on Linux: Linux Release Notes and installation instructions are now available (that wasn't the case when I wrote my Getting Started (Very Preliminarily)... blog post a couple weeks ago). Also, the 2.1 Developer Preview is has advanced to build b11 (I originally downloaded build b9).

The instructions for JavaFX 2.1 on Linux identify the following system requirements:

  • Ubuntu Linux 10.4 or higher (32 or 64 bit)
  • JDK 6 update 26 or higher
  • gtk2 2.18+
  • libavcodec (for media)

I'm running CentOS 5.5, not Ubuntu; my current JDK 6 is prior to update 26; and rpm -q gtk2 tells me that I have gtk2 Version 2.10.4-20.el5. Not the perfect starting point... But, my guess is that likely I'll be able to get a proper configuration in place.

The latest GTK2 that's available via yum for CentOS 5.5 is still in the Version 2.10 sequence. So, I downloaded the last stable GTK2 (Version 2.24.9), and tried installing it. The result of ./configure was a bunch of missing dependencies (too old a version of GLib, and missing atk, pango, cairo, and gdk-pixbuf-2.0). Using yum to see what prepackaged versions of these are available for my CentOS system, I found that in all cases the available packages predate the required versions.

Stepping back to GTK+ 2.18 would help some, but still the dependencies could not be met by simply using the yum package manager.

So, it's a dilemma. I'd like to try out the JavaFX 2.1 Developer Preview on my CentOS system, but there's a pretty big gulf between the CentOS 5.5 packages and what's required for JavaFX 2.1. Attempting big jumps in package versions can break a stable Linux system, in my experience. And the idea of upgrading to a newer operating system isn't all that appealing (that means downtime, and I do have development deadlines to meet). In addition, there are other things I'd like to be working on as well (such as experimenting with the performance differences between various strategies for efficiently utilizing multicore computers -- all that non-JavaFX stuff I was dreaming about last night).

I'll have to think about this for a while... Or, perhaps another night of Java-centric dreaming will provide a solution!


Java.net Weblogs

Since my last blog post, several people have posted new java.net blogs:


Poll

Our current java.net poll asks Under JCP 2.8, EC members lose their voting rights if they miss two consecutive meetings. Your view on this?. Voting will be open until Friday, February 17.


Articles

Our latest Java.net article is Michael Bar-Sinai's PanelMatic 101.


Java News

Here are the stories we've recently featured in our Java news section:


Spotlights

Our latest java.net Spotlight is Heather Van Cura's JCP 2.8 Spec Lead Materials & Adopt-a-JSR update:

Following the upgrade to the JCP 2.8 Program, the Program Office has made available the following materials for Spec Leads on the Multimedia page of jcp.org: -Transparency (December 2011 call) -JCP 2.8 Overview (October 2011 call)...

Previously, we featured Jasper Potts' Curve fitting and styling AreaChart:

I was experimenting today with extending AreaChart to do curve fitting for some example code I was hacking on. It is also a example of what can be done with styling JavaFX charts with CSS. Here is the result...

Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of java.net in the java.net home page archive.

-- Kevin Farnham
Twitter: @kevin_farnham



SwingX 1.6.3 Released

I am very pleased to announce the release of SwingX 1.6.3.  While the release notes contain many fixes, I wanted to take a minute to highlight some of the major changes.

First and foremost, we have more fully adopted Maven.  The project is now a collection of smaller modules. This will make it easier for clients to use only the pieces of SwingX that they need or want.  To enable us to break SwingX into smaller modules, some classes have been moved or reorganized.  Don't worry, we've left a deprecated copy in the original location in all instance but one (I'm looking at you JXBusyLabel.Direction).

Secondly for Maven, we needed to rename our groupId.  Per discussions with the maven.java.net folks, we are now using org.swinglabs.swingx as the groupId.  This is a change from org.swinglabs.  Doing so allows us to use the maven.java.net facitilities for automatically updating Maven Central with our releases.  Future releases should be a lot easier for us in that regard.

The third Maven-related change is that swingx-core no longer contains a copy or dependency on all SwingX classes.  The swingx-graphics package is not used by any of our components.  To suppliment the need to have an all-in-one jar, we have created the swingx-all module which provides all SwingX content as a single JAR file.

To highlight some non-Maven changes, we have:

  • Improved our serialization support.
  • Improved our beaninfo support.
  • Rearchitected our plaf support to allow third party L&F support in the future.
  • Fixed a ton of bugs.
  • Improved our testing style and code coverage.

If anyone is experiencing any issues with out latest release, please let us know over in the forums.  Any feedback, especially about how we divided the code into modules, is always welcomed.

Thanks and enjoy!



Persist document in Cassandra

font:http://www.gerenciandoblog.com.br/2009/08/onde-hospedar-arquivos-para-seu-blog.html


 
 
Nowadays the Enterprise applications beyond persist String and number also can save file. Persist this information is very interesting, for example, a civil process there are information about the process (name of author, date, number of protocol) and the document which represents, or a twett with an image. In Apache Cassandra, you can save file, but for large file you should use a NOSQL Document Store.
 
For demonstrated this resource will made a little program, an album of photography, The picture will show from name. If I use “Paris” will show a picture was related to that name.
 
 
 
 
The program was made with java SE 7 platform, with Swing like GUI, and Easy-Cassandra framework, for this it's necessary download of Easy-Cassandra and its dependencies.
 
The object has two field:
The name of the photo, how this field must be unique it also will the key
The file of the photo
 
The table 1 show the object made.
 
 
@ColumnFamilyValue
public class Photo {
@KeyValue
private String name;
 
@ColumnValue
private File picture;
//getter and setter
}
Table 1: The Object made
 
 
public class PhotoDao {
private Persistence persistence;
public PhotoDao() {
persistence = EasyCassandraManager.getPersistence("exemplo", "localhost", 9160);
}
public void criar(Photo bean) {
persistence.insert(bean);
}
 
@SuppressWarnings("unchecked")
public List<Photo> listarTodos() {
return persistence.findAll(Photo.class,ConsistencyLevelCQL.ALL);
}
}
Table 2: The DAO
 
When the Cassandra is running the next step is create the KeyStore and Family Column, in Cassandra's Client mode execute the command in the table 3.
 
 

create keyspace exemplo; use exemplo;

create column family Photo

with comparator = UTF8Type;

Table 3; Command for run

 
 
 
 
 
This post presented the persistence of an document or file with a simple example. This resource is useful and easy of use. The Easy-Cassandra has support with java.io.File and all classes who implement java.nio.file.Path.
 
 

Reference:

Easy-Cassandra: https://github.com/otaviojava/Easy-Cassandra/
 Example program with Eclipse and Netbeans: https://github.com/otaviojava/Easy-Cassandra/downloads

 

 



Bundling Gems in Jars/Wars for Jruby

 

As part of Virgil's ability to deploy ruby scripts to a remote Hadoop cluster, we needed to package gems' into that Hadoop jar.  After a bit of monkeying around, we got it.

This is the key piece of information:

"Because the operation of Java's classpath and Ruby's load path are so similar, especially under JRuby, they are unified in JRuby 1.1. This results in a number of unified capabilities:...

 

  • Everything in the Java classpath is considered to be a load path entry, so .rb scripts, for example, contained in JAR files, are loadable."

First thing you need is to actually get your hands on the gem.  To do this, you can run jruby to grab the gem.

 

java -jar jruby-complete-1.6.0.jar -S gem install -i rest-client rest-client --no-rdoc --no-ri


This will fetch the gems and install them into the current directory under the directory "rest-client".  In that subdirectory you'll find: bin, cache, doc, gems and specifications.  The actual code for the gems is found in the gems directory.  In the case of rest-client, you'll find two directories that contain the code: mime-types-1.17.2 and rest-client-1.6.7.

 

This is what you need to bundle into the jar.  We copied those two directories into our java project under src/main/resources/gems/.

 

One approach would be to simply include those directories on your classpath.  Another approach is to programmatically adjust the loadpath to include those directories.   You can do this with the following lines:

 

List paths = new ArrayList(); 

paths.add("gems/rest-client-1.6.7/lib/"); 

paths.add("gems/mime-types-1.17.2/lib/"); 

this.rubyContainer = new ScriptingContainer(LocalContextScope.CONCURRENT); this.rubyContainer.setLoadPaths(paths);

 

Then, when using this.rubyContainer you'll be able to run ruby files that require the rest-client.

 

Since the ruby scripts are actually loaded via the classpath (from the loadpath), jruby is happy loading them from within a jar.  In our case, we built the jar using maven and the gems were included in the jar because we put them under src/main/resources/gems.

 

 

 

 



Guest Post: Is Java the best language to meet my needs?

This email came into our site feedback alias this morning, and I thought this would be a great topic to ask the community.  I'm a big believer in using the right tool for the job, even if it's not Java at the moment.  I asked his permission to post it here, so please meet Mike: 

To whom it may concern,

I need your advice.  Back in 2000 I was a post-doctor at the University of Caledonia in Berkeley.  While there, I became ill with a type of brain cancer called a medulloblastoma, and was forced out of research.

After release from the hospital, I started programming rehabilitation games similar to the ones used in brain injury rehabilitation.  I decided to do this because these types of games, although a medical tool, are quite expensive.  I wanted to produce my own version of these games that were free.  The results of my efforts can be seen at http://www.msty-neurotraining.com and are registered at the Brain Injury Association of America (http://www.biausa.org/) as a rehabilitation tool.


However, I have a serious problem.  These programs were made using Microsoft’s Visual Basic 6, and the programs made with it will soon become obsolete and no longer run modern versions of Windows computers. Therefore, I am looking for an alternative.  Preferably one which is open source (like Java) to keep in spirit that the games are a free medical tool.   Do you have any suggestions as to what open source programming language would be appropriate for my needs? I need something that can produce programs capable to manipulate 2D graphics, save and retrieve files and use a joystick.  I am not restricted to using a programming similar to Visual Basic; I can also program in C++ (the programming language we predominantly used at Berkeley).

Would Java be a good alternative to Microsoft’s Visual Basic?  If not, what other programming tool would you advise using?

Also, how do I go about starting an Open Source project to create a rehabilitation tool like the one the I created with VB6?  Starting such a project would be preferable to working alone, because I feel that a team working together always gets better results than an individual working alone.

Sincerely,

Michael Tarsitano (PhD)
Bruchsal, Germany

 



JCP's Evolution into Openness Continues: Lost Voting Rights and JSR 355

I was surprised to read the JCP Program Office's recent announcement that AT&T, Samsung, and SK Telecom have all lost their Executive Committee (EC) voting rights. The reason? Well, the JCP EC meeting held earlier this month was the second held under the new JCP 2.8 EC Standing Rules. Under those rules, if an Executive Committee member misses two consecutive meetings, they lose their voting privileges. AT&T, Samsung, and SK Telecom missed the last two EC meetings, so they'll have no voting rights for a while (see their names highlighted in RED on the current JCP minutes page).

To me, this is refreshing. It shows that, under the JCP 2.8 rules, membership on a JCP Executive Committee isn't just a title for a company (or individual) to highlight on their web site or resume. A responsibility is entailed. If you're not going to fulfill your obligation to attend the meetings, then you won't have a say in what happens next.

Also, it seems to me that an EC member's attendance record will now matter when the next EC election comes up. That's a very good thing too, I think. If you're on the EC, attend the meetings -- or step aside, and let someone who genuinely wants to participate take your place.

So, if you miss two consecutive meetings, you lose your voting rights (along with your right to make or second a motion). If you miss five consecutive meetings, or if you miss 2/3 of all the meetings that take place in any 12-month period (EC meetings typically occur on a monthly basis), you are booted off the Executive Committee entirely (regardless of how major you are in the marketplace, or how famous you may be as an individual).

Now, if after you lose your voting rights, you decide you want to take your EC membership seriously, you can regain your voting privileges: by attending two consecutive upcoming meetings. I hope AT&T, Samsung, and SK Telecom will all decide to do that. There are very good reasons why JCP members voted them into their Executive Committee seats. It's time for them to fulfill the roles they were elected to fulfill.

JSR 355: JCP.Next, Part 2

The JCP Program Office also announced Another JCP.Next JSR submitted. This is JSR 355: JCP Executive Committee Merge. In her post about the new submission, the JCP's Heather Vancura-Chilson summarizes the main thrust of the JSR as follows:

this JSR proposes to make changes to the JCP's Process Document and the Executive Committee's Standing Rules with the goal of merging the two Executive Committees into one and reducing the total number of Executive Committee members from the current total of 32. The existing two-to-one ratio of ratified to elected seats will be maintained. On the merged EC neither Oracle nor any other member may hold more than one seat.

At JavaOne, we saw a vision of an across-the-board synchronization of the Java platform presented, wherein all facets of the Java platform, from editions for the smallest devices to Java EE preparing for the emergence of data centers in the cloud, will be driven toward consistency. Loose strands will be brought back toward the core Java platform. If this is indeed the vision, indeed the plan, then it makes a lot of sense to have only a single Java Community Process Executive Committee.

JSR 355 is yet another excellent move for the JCP, in my view. And the fact that the JCP 2.8 rules clearly delineate the responsibility of members to take their positions seriously -- that's great for Java and the Java/JVM developer community as well. Nice work, JCP!


Java.net Weblogs

Since my last blog post, Sanjay Dasgupta posted an interesting new java.net blog:


Poll

Our current java.net poll asks for your response to In 2012, job opportunities for Java/JVM developers will.... Voting will be open until Friday, February 3.


Articles

Our latest Java.net article is Michael Bar-Sinai's PanelMatic 101.


Java News

Here are the stories we've recently featured in our Java news section:


Spotlights

Our latest java.net Spotlight is Tori Wieldt's JUG Leaders Conference:

The annual International Oracle User Group (IOUC) Leader's Conference was held this week in at Oracle in Redwood Shores, California. The conference provides three days of learning, networking, sharing, and collaboration about user groups. It also fosters better communication between user group leaders...

Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of java.net in the java.net home page archive.

-- Kevin Farnham
Twitter: @kevin_farnham

AttachmentSize
JCP.png7.11 KB


Vulcan-ized Rhino: Telepathic Power for your Code

In this article we coax the JVM's Rhino (an elusive, misunderstood, and ignored member of the ecosystem) into a mind meld, giving it access to the JVM's thoughts, experiences, memories, and knowledge; and take it where no Rhino has gone before !

Let me set the context with some quick code:

ScriptEngineManager sem = new ScriptEngineManager(); 
ScriptEngine jsEngine = sem.getEngineByName("javascript"); 
    ... 
String message = "Hello rhino!"; 
    ... 
jsEngine.eval("println(message)");

Everyone knows that this code does not work (it produces a "ReferenceError: "message" is not defined"). To make it work the variable message must be put into the script engine's bindings, as described in these articles. That's easily done. But the overhead and distraction of the extra boilerplate makes the body of code much less intuitive. (The 4-line example above already has 2 lines of distracting boilerplate!)

A Quick Example

What can we do to make something as simple as "println(message)" in a script just work? In fact, let's raise the bar some more. Take a look at Sqrt.java. Let's say you were explaining that code to a novice, and wanted to provide a probe into the while loop of the running program, by adding the line in red:

    ...
while (Math.abs(t - c/t) > epsilon*t) {
    t = (c/t + t) / 2.0;
    if (args.length == 2) 
        VulcanRhino.eval(args[1]);
}
    ...

Think of class VulcanRhino as your friendly telepathic pachyderm, and eval() its static, void JavaScript evaluator. The idea is that a JavaScript snippet could be passed into the program as an optional second command-line argument. That snippet (specified at run time) could contain logic with references to any of the in-scope Java variables. The code above is a simple example. But this approach allows you to include any number of VulcanRhino.eval()s, located wherever the invocation of a static void function would be legal, each executing a different script. Each invocation of VulcanRhino.eval() has access to all in-scope variables at its location.

Our modified Sqrt.java would run normally (doing nothing unusual) if run with just one command-line argument, but giving it a second argument awakens the slumbering telepath. Here are a few sample runs (the different colors separate the command line from the program's output) ...

See how "t" evolves Track value of "c/t"
> java Sqrt 49 "println(t)"
49
25
13.48
8.557507418397627
7.141736912383411
7.001406475243939
7.000000141269659
7.000000000000002
> java Sqrt 49 "println(c/t)"
1
1.96
3.635014836795252
5.725966406369197
6.861076038104466
6.9985938072953795
6.999999858730344
7.000000000000002

The last line of output (struck out) is not from the script, but is the program's normal 1-line output. The examples above use scripts to track the values of "t" and "c/t" respectively. But you are free to pass in any expression that makes sense at the location of VulcanRhino.eval(). You may even use it for something completely unforeseen ...

Timing the loop Memory problem?
> java Sqrt 49 
"println(java.lang.System.
currentTimeMillis())"
1327399502966 1327399502970 1327399502973 1327399502974 1327399502975 1327399502976 1327399502977 7.000000000000002
> java Sqrt 49 
"println(java.lang.Runtime.
getRuntime().freeMemory())"
30472936 30472936 30472936 30472936 30308384 30308384 30308384 7.000000000000002

The one thing you can not do with a script in this way is to assign a value to a variable.

The Vulcan-Rhino User Guide

To use this approach, you must pre-process your source-code using a tool described below. This step is the key to the magic -- it augments each VulcanRhino.eval() in your code with something that gives it access to all the in-scope variables. So, proceed as follows:

  • edit your program (say Sqrt.java), adding VulcanRhino.eval()s as required, and save it with a different name (say SqrtVR.java)
  • pre-process SqrtVR.java following instructions below. Save the output as Sqrt.java. Note: this overwrites any other Sqrt.java
  • run as usual, making sure that class VulcanRhino is on the classpath. The VulcanRhino.java source should be compiled and deployed as required.

To pre-process a file use the following command:

java >Sqrt.java -cp VLL4J.jar net.java.vll.vll4j.api.Vll4j VulcanRhino.vll SqrtVR.java

The files used are described below:

If you have trouble with the above steps, check the following:

  • does a SqrtVR.java file exist?
  • have you edited SqrtVR.java to add VulcanRhino.eval(args[1])
  • copy and paste the command line above directly
  • ensure VulcanRhino has been compiled and exists on the classpath

How Does it Work?

Let's first get VulcanRhino out of the way. Observe that eval() does nothing special, but there is another function defVars() that enables the caller to inject information about variables into the JavaScript engine.

import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class VulcanRhino {
    public static void eval(String script) {
        try {
            engine.eval(script);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static void defVars(Object... args) {
        engine.getBindings(ScriptContext.ENGINE_SCOPE).clear();
        for (int i = 0; i < args.length; i += 2) {
            String name = (String)args[i];
            Object value = args[i + 1];
            engine.put(name, value);
        }
    }
    static ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
}

Next take a look at the pre-processed version of Sqrt.java.

    ...
while (Math.abs(t - c/t) > epsilon*t) {
    t = (c/t + t) / 2.0;
    if (args.length == 2)
        {VulcanRhino.defVars("epsilon", epsilon, "c", c, "t", t, "args", args); VulcanRhino.eval(args[1]);}
}
    ...

The part you added is still in red. But the pre-processor has spliced in the blue text. The pre-processor makes this change at each occurrence of VulcanRhino.eval(...), injecting information about the locally visible variables into the JavaScript engine.

Pre-Processor Internals

I won't go into all the details here, presuming that not everyone is interested. So the remaining part of the article is a short summary of the technique together with links to all the other material you will need to understand the details.

The pre-processor uses a parser for the Java language to analyze your program and obtain information about which variables are visible at each VulcanRhino.eval(...) location. It then modifies the source code by wrapping each VulcanRhino.eval(...) in a block ({ ... }) preceded by a VulcanRhino.defVars(...) call that injects the information required into the JavaScript engine.

The parser-generator used is the easily learned, completely visual tool VisualLangLab. For an introductory tutorial look at A Quick Tour. Scala programmers will find Rapid Prototyping for Scala useful too.

The last piece of the puzzle is in the grammar file VulcanRhino.vll. This file contains a Java grammar modified with action functions that perform the pre-processing. To examine the grammar, its rules, and the code in the action functions, proceed as follows:

  • double-click VLL4J.jar (the same file used in the pre-processing step described above). this will start up the VisualLangLab GUI as shown in Figure-1 below
  • select "File" -> "Open" from the main menu, choose the grammar file VulcanRhino.vll, then click the Open button
  • in the rule-tree (the JTree at the left of the GUI) select (click on) the node just below the root node (see red arrow). This will cause the action-code associated with this parser-rule to be displayed under Action Code (right side of the GUI). This is the code (in JavaScript) that pre-processes your code

Using VisualLangLab
Figure-1 VisualLangLab GUI with VulcanRhino grammar loaded

The information used by the action-code above is in several global variables (VLL members). That information is gathered by other action-code in other rules. To examine all the remaining code proceed as follows:

  • select the rule named block (use the combobox in the toolbar), and click on the reference node labeled blockStatement
  • select the rule variableDeclaratorId, and click on the sequence node just below the root node
  • select statement, click on the node just below the token node for FOR

If you do want to pursue this further, a thorough reading of A Quick Tour is strongly recommended. You will also need AST and Action Code and Editing the Grammar Tree.

AttachmentSize
Using-VisualLangLab.png49.78 KB


Getting Started (Very Preliminarily) with JavaFX 2.1 Developer Preview on Linux

Yesterday, Jonathan Giles announced that the JavaFX 2.1 Developer Preview, build 09, is available for Windows, Mac and Linux! Jonathan says, "From here on out we'll be putting out developer preview builds for all three platforms." That this is news that a lot of people have been long awaiting is shown by the immediate response (seven comments) to Jonathan's brief (three sentences) announcement.

I've been waiting for this myself, since I'm starting work on a new open source project (related to efficient use of multicore processors in desktop applications), and I've wanted to be able to use JavaFX as a front end for my demos (or, at least offer it as an option). My preferred platform is Linux (though I also have an old MacBook and a Windows machine). My primary development machine runs CentOS 5.5 (equivalent to RedHat Enterprise Linux, but with no non-free packages).

So, let's get started!

Before you download JavaFX 2.1 build b09, you must accept the OTN License Agreement (I looked for a link to the license, just for reference, but didn't immediately find it). Also, I had to log in to my Oracle account in order to actually receive the download.

The Mac OS X and Linux downloads are in zip format. Once I'd logged in, I was able to save the file, javafx_sdk-2_1_0-beta-b09-linux-i586-17_jan_2012.zip, onto my system. At present, there isn't a link that provides installation instructions for the Linux edition. An


unzip javafx_sdk-2_1_0-beta-b09-linux-i586-17_jan_2012.zip

creates a javafx-sdk2.1.0-beta directory. Diving into that, you'll see COPYRIGHT.html, README.html, THIRDPARTYLICENSEREADME.txt, and directories bin, docs, rt, and tools. README.html sends you to Oracle's JavaSE README page, which includes README's for the JavaFX 2.0 runtime and SDK. So, that's not your path to installing JavaFX 2.1 on Linux.

Poking around a bit more, it suddenly dawned on me that maybe the unzip operation itself was the install. Aside from PATH settings, of course (since I did the unzip in a somewhat arbitrary location).

The docs subdirectory consists of documentation of the API itself. The bin subdirectory contains the javafxpackager, a shell script internally documented as being the "JavaFX Packager tool execution script for Linux/Solaris/OS X."

It's interesting that OS X is lumped in with Linux and Solaris, right? So, I clicked the Mac OS X installation instructions and release notes link, which brings you to a page titled "JavaFX 2.1 Developer Preview for Mac OS X Release Notes." This page includes a link to instructions for setting up NetBeans with JavaFX 2.0 -- which is how I was planning on getting started anyway. It also talks about the JavaFX Samples available on the downloads page; but, again, there is no link for "Linux" in that section of the page.

The next step in my investigation will be to see if I can get any of the simple Mac OS samples work under Linux. Whether that works out or not, the step after that will be to see if I can make my own first very simple JavaFX app that runs on CentOS Linux.


Java.net Weblogs

Since my last blog post, several people have posted interesting new java.net blogs:


Poll

Our current java.net poll asks for your response to In 2012, job opportunities for Java/JVM developers will.... Voting will be open until Friday, February 3.


Articles

Our latest Java.net article is Michael Bar-Sinai's PanelMatic 101.


Java News

Here are the stories we've recently featured in our Java news section:


Spotlights

Our latest java.net Spotlight is Markus Eisele's The Heroes of Java: Trisha Gee:

The 11th part of my "Heroes of Java" interview series. Thanks for following it! Stay tuned for the next parts! Trisha is a developer at LMAX, the London Multi Asset eXchange. She's been working in financial markets for the last 5 years or so...

Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of java.net in the java.net home page archive.

-- Kevin Farnham
Twitter: @kevin_farnham



Persisting information with Cassandra in java: Simple example


This article has the main objective show a little example for persist information in Cassandra using java.

For demonstrated the persistence with Cassandra will used the Easy-Cassandra, a framework open source for use this SGBG in an easy mode.
 
@ColumnFamilyValue(nome = "person")//
public class Person implements Serializable {
 
private static final long serialVersionUID = 3L;
@KeyValue(auto=false)
private Long id;
@IndexValue
@ColumnValue(nome = "name")
private String name;
@ColumnValue(nome = "year")
private Integer year;
@EnumeratedValue(nome="sex") campo
private Sex sex;
@EmbeddedValue
private Address address;
//getter and setter
}
 
 
 
public class PersonDAO {
 
private Persistence persistence;
 
public PersonDAO() {
persistence = EasyCassandraManager.getPersistence("javabahia", "localhost", 9160);
}
 
public void create(Person bean) {
persistence.insert(bean);
}
 
 
public void remove(Person bean) {
persistence.delete(bean);
}
 
public void remove(Long id){
persistence.deleteByKeyValue(id, Person.class);
}
public void update(Person bean) {
 
persistence.update(bean);
 
}
 
public Person retrieve(Object id) {
return (Person) persistence.findByKey(id, Person.class);
}
 
@SuppressWarnings("unchecked")
public List<Person> listAll() {
return persistence.findAll(Person.class);
}
 
 
@SuppressWarnings("unchecked")
public List<Person> listByIndex(Object index) {
return persistence.findByIndex(index, Person.class);
}
 
}
 
 
The source can be downloaded in a link, in the end of article, when you are seeing the source can see the annotations bellow:
 
 
  • ColumnFamilyValue: annotations for identify the family column name
  • ColumnValue: for identify the column in the Family Column, the classes can be used are:
  • java.lang.Boolean
  • java.util.Date
  • java.lang.Double
  • java.lang.Float
  • java.lang.Integer
  • java.lang.Long
  • java.lang.String
  • EmbeddedValue: The class with this is annotation has fields with ColumnValue inside itself, but the persistence way continues in the same Family of the Column. This annotation is to do the object’s modeling easily.
  • EnumeratedValue: for be used in Enums
  • IndexValue: The field with this annotation is an index, can search and retrieve information from the row like KeyValue, need also use the ColumnValue together with this annotation.
  • KeyValue: The field with this annotation is an Key of the Row. If the auto value is true will generate auto increment, each new Key in the FamilyColumn there are a new value auto numeric.
 
The annotation ColumnFamilyValue, ColumnValue and EnumeratedValue if the value “name” be empty the value default is the Field's name.
 
After see the code let go that for run, so you need:
 

 
  • JDK 7 or above
For run the example follow this the steps:
 
  • Do download of the apache-cassandra in: Here
  • After that, unzip the file downloaded and enter it.
  • Execute the command when you stay in Cassandra home:
./bin/cassandra -f
  • For execute the client's mode, also in Cassandra'home execute the command bellow:
./bin/cassandra-cli -host localhost
 
  • In the Client's mode run the script bellow:
 
create keyspace javabahia; use javabahia; create column family person with comparator = UTF8Type and column_metadata = [ {column_name: name, validation_class: UTF8Type, index_type: KEYS} ];

 

  • Download and add in ClassPath of the Project, the Easy-Cassandra's lib:
  • You will have two choices of Download:
  • Only the Easy-Cassandra's lib
  • The Easy-Cassandra's lib with its dependencies (The Libs of the Thrift)
This article has like main objective show a little some persist of information in apache-Cassandra, for this was used a little example that is available in Netbeans and Eclipse IDE.

Reference:
 
Download of sources and libs
 
 
Wiki Easy-Cassandra:
 
 
home Easy-Cassandra:
 
 
 

 



Using Maven for more than development

I think that Maven is a great tool for development. But it can be used for more. For instance, I've just prepared things so that starting from a clean room you can try out my lightweight CMS, NorthernWind, by just invoking a couple of commands. They will install and run NorthernWind, an embedded server and an example site. More information at the NorthernWind blog.




All brand names,logos and trademarks in this site are property of their respective owners.

-  Free Magazines


Free Magazine
-  News
Java/J2EE/J2ME
  java.sun.com
  TheServerSide
  Wireless Java
  Javable
.NET
  MSDN
Certification
  CertCities
  MCPMag
Industry News
  CNET News
  CNET E-Business
  CNET Enterprise
  InfoWorld
  eWeek
  WiredNews
-  Weblogs
JavaBlogs
James Gosling's
-  Tell A Friend
Tell others

DailyTutorials
Free Magazine World
Free Study Guides
Free eBooks |  About |  Disclaimer |  Terms Of Use |  Privacy Policy
Copyright 2001-2006 Gayan Balasooriya.   
All Rights Reserved.