Now you can track your stolen laptop / phone (but not iPhone yet) for free using an open source software called Prey. It is a very small & lightweight software that can be installed on your Mac, Windows, Linux or Ubuntu Laptop or your Android smart Phone. Set it up and then you can wake it up in case your device is (God forbid) stolen. There are paid Pro version too for those who want a greater feature set and active monitoring.
This was recently used by self professed Info Sec Evangelist Greg Martin to track his stolen MacBook in the aftermath of the London riots.
Thursday, August 18, 2011
Tuesday, August 2, 2011
Java 7 Summary of New Features
Here is a summary of the new features released in Java 7 as part of Project Coin language enhancements are:
- Improved Numeric Literals - Binary integral literals and Underscore in numeric literals
- Strings in switch
- Diamond operator or simpler type inference for generic instance creation
- try-with resource statement
- Multi-catch and more precise throw
- Simplified varargs method invocation
- Fork & Join enhancements
- NIO 2.0 & File system access enhancements
These are explained in detail below.
Improved Numeric Literals
Integral types (byte, short, int, and long) can also be expressed using the binary number system by prefixing "0b" or "0B" to the number's binary representation as:
int binaryLiteral = 0b110011
You can have underscores in numeric literals to make them more readable like:
int tenMillion = 10_000_000;
Strings in switch
Till Java6, only numbers or enums could be used in switch statements. Now strings are also allowed:
String switchString = getStringValue();
switch(switchString) {
case "foo": doFoo();
break;
case "bar": doBar();
break;
case "fuu": doFuu();
break;
default: doDefault();
break;
}
Diamond operator
This is a short cut to reduce typing and make it simpler to infer generic types during instance creation
Map<String, List<Pair<String,BigDecimal>> myMap = new HashMap<>();
Simplified varargs method invocation
When a programmer tries to invoke a *varargs* (variable arity) method with a non-reifiable varargs type, the compiler currently generates an "unsafe operation" warning. This proposal moves the warning from the call site to the method declaration. This merits more detailed explanation and a separate post.
Multi-catch and more precise throw
Now you can catch multiple exceptions in the same catch clause and also re-throw final exceptions without declaring the method with the "throws" clause. More Precise Rethrow allows you to catch a high level exception instead of each possible exception, but when you re-throw this caught exception, the correct sub-class is thrown instead of the higher level exception. This merits more detailed explanation and a separate post.
Fork & Join threading enhancements
New Fork / Join framework as an implementation of the ExecutorService to help take advantage of mulit-core / multi-processor machines.
NIO 2.0 & File system access enhancements
NIO 2.0 & File system related changes make it easier for traversing file system trees and access file properties.
There are numerous changes and these could be a good candidate for a separate book in itself.
Check out the Summary of Java 5 features that are also hold good and are very useful.
Fork & Join threading enhancements
New Fork / Join framework as an implementation of the ExecutorService to help take advantage of mulit-core / multi-processor machines.
NIO 2.0 & File system access enhancements
NIO 2.0 & File system related changes make it easier for traversing file system trees and access file properties.
There are numerous changes and these could be a good candidate for a separate book in itself.
Check out the Summary of Java 5 features that are also hold good and are very useful.
Java Diamond "<>" operator
As part of Project Coin - Language enhancements, Java 7 has introduced the Diamond operator "<>".
In reality, this is just a short cut for a simpler type inference for generic instance creation.
So instead of this:
one can use this in Java7:
So you say "big deal"?! The real benefits show when the type being inferred is very complicated and has multiple types nested in it like:
You are saved from repeating the same thing - less typing and less errors!
In reality, this is just a short cut for a simpler type inference for generic instance creation.
So instead of this:
List<String> stringList = new ArrayList>String>();
one can use this in Java7:
List<String> stringList = new ArrayList<>();
So you say "big deal"?! The real benefits show when the type being inferred is very complicated and has multiple types nested in it like:
Map<String, List<Pair<String,BigDecimal>> myMap = new HashMap<>();
You are saved from repeating the same thing - less typing and less errors!
Friday, July 29, 2011
Eclipse support for Java7
Good news for Eclipse users is that all new builds of Eclipse 3.7.1, 3.8 and 4.2 will now fully support Java 7.
Earlier development of Java7 support in Eclipse was being done in BETA_JAVA7 branch which now has been fully merged into the HEAD and the R3_7_maintenance branch.
So the implication is that if you want Java7 support, you need to move to the latest builds of Eclipse Indigo (3.7.x) or higher. Cannot use Eclipse Helios (3.6.x) or even the initial versions of Indigo as the older JDT & Core packages do not understand the new Java7 features as Eclipse uses its own compiler and the ones built into older versions of Eclipse do not support Java 7. Also, as noted in the Project Plan For Eclipse Project, version Helios, support for Java 7 is deferred and decoupled from the 3.6 release since Java 7 release will be after the official release of 3.7.
Note that you will need to download a 3.7 maintenance build (>= M20110729-1400), a 3.8 build (>= I20110729-1200), a 4.1 maintenance build (coming soon) or a recent 4.2 build (>= I20110729-0200) to get Java7 support in Eclipse.
Earlier development of Java7 support in Eclipse was being done in BETA_JAVA7 branch which now has been fully merged into the HEAD and the R3_7_maintenance branch.
So the implication is that if you want Java7 support, you need to move to the latest builds of Eclipse Indigo (3.7.x) or higher. Cannot use Eclipse Helios (3.6.x) or even the initial versions of Indigo as the older JDT & Core packages do not understand the new Java7 features as Eclipse uses its own compiler and the ones built into older versions of Eclipse do not support Java 7. Also, as noted in the Project Plan For Eclipse Project, version Helios, support for Java 7 is deferred and decoupled from the 3.6 release since Java 7 release will be after the official release of 3.7.
Note that you will need to download a 3.7 maintenance build (>= M20110729-1400), a 3.8 build (>= I20110729-1200), a 4.1 maintenance build (coming soon) or a recent 4.2 build (>= I20110729-0200) to get Java7 support in Eclipse.
Java 7 GA release finally available
Java 7 was finally release into the wild today and made "GA" - Generally Available!
Download the latest from here.
Here's a very high level list of the new features/changes that made into Java7:
VM
Language
Core
Internationalization
I/O & Networking
Security & Cryptograpphy
Database Connectivity
Client
Web
Management
Pheww - that was a long list to say the least ;) No wonder the release date for Java7 was a very difficult moving target.
I will be putting out a detailed post on each of the features soon - so keep watching this space!
Download the latest from here.
Here's a very high level list of the new features/changes that made into Java7:
VM
- Support for dynamically-typed languages using the new InvokeDynamic instructions
- Strict class-file checking
Language
- Small language enhancements from Project Coin like Strings in switch statements, try-with-resources statements, diamond operator, etc.
Core
- Upgrade class-loader architecture to avoid deadlocks in non-hierarchical class-loader topologies
- Concurrency and collections updates in form of a lightweight fork/join framework, flexible and reusable synchronization barriers, transfer queues, concurrent linked double-ended queues, and thread-local pseudo-random number generators
Internationalization
- Support for Unicode 6.0
- Separate handling of locales to separate formatting locales from user-interface language locales
I/O & Networking
- New APIs for filesystem access, scalable asynchronous I/O operations, etc
- New NIO.2 filesystem provider for zip and jar files
- API for the Stream Control Transmission Protocol (SCTP) on Solaris
- SDP (Sockets Direct Protocol) support for reliable, high-performance network streams over Infiniband connections on Solaris and Linux
- Networking code modified to use the Windows Vista IPv6 stack, when available, in preference to the legacy Windows stack
- Support for Transport Layer Security version 1.2
Security & Cryptograpphy
- Implementation of the standard Elliptic Curve Cryptographic (ECC) algorithms to allow Java programs to support it out of the box
Database Connectivity
- JDBC 4.1 and Rowset 1.1
Client
- New Java2D graphics pipeline based upon the X11 XRender extension, which provides access to much of the functionality of modern GPUs
- New platform APIs for features originally implemented in the 6u10 release namely Translucent and shaped windows, and heavyweight/lightweight component mixing
- Cross-platform Nimbus look-and-feel for Swing
- SwingLabs JXLayer component decorator added to the platform
- New Gervill sound synthesizer created and made available
Web
- Upgrade of the components of the XML stack to the most recent stable versions: JAXP 1.4, JAXB 2.2a, and JAX-WS 2.2
Management
- Enhanced MBeans to report the recent CPU load of the whole system, the CPU load of the JVM process, and to send JMX notifications when GC events occur
Pheww - that was a long list to say the least ;) No wonder the release date for Java7 was a very difficult moving target.
I will be putting out a detailed post on each of the features soon - so keep watching this space!
Thursday, July 21, 2011
Conditional Breakpoints in Eclipse
If you have a big data set that you are using to test changes that apply to specific scenarios or rows, Eclipse conditional breakpoints can help to make life easier and simpler.
In Debug View (obviously!), right-click on the breakpoint that you want to make conditional and in the window that opens up, check "Enabled" box and then the "Conditional" box. This enables the textarea below it where you can enter any valid java expression which should trigger this breakpoint when true.
Optionally, you can also check the "Hit count" box and enter a positive number to make this breakpoint trigger after that many number of iterations.
In Debug View (obviously!), right-click on the breakpoint that you want to make conditional and in the window that opens up, check "Enabled" box and then the "Conditional" box. This enables the textarea below it where you can enter any valid java expression which should trigger this breakpoint when true.
Optionally, you can also check the "Hit count" box and enter a positive number to make this breakpoint trigger after that many number of iterations.
Wednesday, May 25, 2011
Change format of Date displayed in SQL Developer
To change the format of Date column displayed in SQL Developer worksheets (output of SQL queries) do the following:
- Select Tools > Preferences
- Expand the Database section
- In the NLS Date format field, enter the desired date format as supported by Oracle
Tuesday, April 5, 2011
Restore MS SQL Server Backup file
Recently I was faced with a dilemma - a friend of mine had a M$ SQL Server backup file and wanted me to extract some data from it. Since I work on Ubuntu & LAMP stack, I had to grab hold of a Win7 laptop and then follow the below steps.
To restore a database you need to do three things:
Assume: For this example, the backup file is C:\Backups\DB_Backup_20110131.bak
Step 1: Install MS SQL Server
Go to Micro$oft site using the direct link http://www.microsoft.com/express/Database/I-nstallOptions.aspx and download and install the most appropriate version of SQL Server Express.
Step 2: Interrogate Backup File
This will return something like the below set of rows which represent the internal logical composition of the backup file:
Step 3: Restore from Backup File
To restore a database you need to do three things:
- Install MS SQL Server Express
- Interrogate the backup file to find the logical file names it contains
- Restore the file into the appropriate database
Assume: For this example, the backup file is C:\Backups\DB_Backup_20110131.bak
Step 1: Install MS SQL Server
Go to Micro$oft site using the direct link http://www.microsoft.com/express/Database/I-nstallOptions.aspx and download and install the most appropriate version of SQL Server Express.
Step 2: Interrogate Backup File
RESTORE FILELISTONLY FROM DISK = 'C:\Backups\DB_Backup_20110131.bak'
This will return something like the below set of rows which represent the internal logical composition of the backup file:
LogicalName PhysicalName Type FileGroupName Size MaxSize ------------------ ---------------------------- ---- ------------- --------- -------------- SourceDatabase_data C:\SqlServer\Src_DB_Data.mdf D PRIMARY 836461765 35184372080640 SourceDatabase_log C:\SqlServer\Src_DB_Log.ldf L NULL 91592723 35184372080640
Step 3: Restore from Backup File
RESTORE DATABASE Destination_DB
FROM DISK = 'C:\Backups\DB_Backup_20110131.bak'
WITH
REPLACE, -- Overwrite DB - if one exists
RECOVERY, -- Use if this is the only file to recover
STATS = 10, -- Show progress (every 10%)
MOVE 'SourceDatabase_data' TO 'C:\SqlServer\Src_DB_Data.mdf',
MOVE 'SourceDatabase_log' TO 'C:\SqlServer\Src_DB_Data.mdf'
Array Equality in JUnit
Till JUnit4.2.*, the only way to compare equality of arrays was to use the following snippet of code:
JUnit4.3.* added the assertArrayEquals methods but surprisingly omitted a method to compare arrays of primitive doubles so, one had to fall back to the above mentioned way to compare them.
This important feature was added in JUnit4.6 so if you are using that or a later version, you can do the following:
The advantage with using the assertArrayEquals method over the previous method is that this method clearly indicates the first element which differed. For example, when the below basic test is run, it gives the error message:
Here is a sample class file showing implementation of the above test:
assertTrue(java.util.Arrays.equals(primitiveArray1, primitiveArray2));
JUnit4.3.* added the assertArrayEquals methods but surprisingly omitted a method to compare arrays of primitive doubles so, one had to fall back to the above mentioned way to compare them.
This important feature was added in JUnit4.6 so if you are using that or a later version, you can do the following:
assertArrayEquals(doubleArray1, doubleArray2, delta)where delta is the allowed tolerance.
The advantage with using the assertArrayEquals method over the previous method is that this method clearly indicates the first element which differed. For example, when the below basic test is run, it gives the error message:
arrays first differed at element [2]; expected:<2.3124> but was:<2.3224>
Here is a sample class file showing implementation of the above test:
import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;
public class AAETest {
@Test
public void testAAEDouble() {
double[] da1 = {1.002d, 1.234d, 2.3124d, 3.91293d};
double[] da2 = {1.003d, 1.2345d, 2.3224d, 3.91293d};
double tol = 0.001d;
assertArrayEquals(da1, da2, tol);
}
}
Comparison of Intel Atom processors
With the various Atom Processor based netbooks and nettops being available these days, it becomes very difficult to decide which one to go for. Searching for the differences between the processors, I found the following comparison chart:
This is taken from the Intel Ark site.
Now based on the above table, the decision making process is slightly easier!
| Product Name | Max TDP | Cores / Threads | Intel® VT-x | Integrated Graphics | Intel® Turbo Boost Technology | Status |
|---|---|---|---|---|---|---|
| Intel® Atom™ Processor Z560 (512K Cache, 2.13 GHz, 533 MHz FSB) | 2.5 Watts | 1C / 2T | Yes | No | Launched | |
| Intel® Atom™ Processor Z550 (512K Cache, 2.00 GHz, 533 MHz FSB) | 2.4 Watts | 1C / 2T | Yes | No | Launched | |
| Intel® Atom™ Processor Z540 (512K Cache, 1.86 GHz, 533 MHz FSB) | 2.4 Watts | 1C / 2T | Yes | No | Launched | |
| Intel® Atom™ Processor Z530P (512K Cache, 1.60 GHz, 533 MHz FSB) | 2.2 Watts | 1C / 2T | Yes | No | Launched | |
| Intel® Atom™ Processor Z530 (512K Cache, 1.60 GHz, 533 MHz FSB) | 2 Watts | 1C / 2T | Yes | No | Launched | |
| Intel® Atom™ Processor Z520PT (512K Cache, 1.33 GHz, 533 MHz FSB) | 2.2 Watts | 1C / 2T | Yes | No | Launched | |
| Intel® Atom™ Processor Z520< (512K Cache, 1.33 GHz, 533 MHz FSB) | 2 Watts | 1C / 2T | Yes | No | Launched | |
| Intel® Atom™ Processor Z515 (512K Cache, 1.20 GHz, 400 MHz FSB) | 1.4 Watts | 1C / 2T | No | No | Launched | |
| Intel® Atom™ Processor Z510PT (512K Cache, 1.10 GHz, 400 MHz FSB) | 2.2 Watts | 1C / 2T | No | No | Launched | |
| Intel® Atom™ Processor Z510P (512K Cache, 1.10 GHz, 400 MHz FSB) | 2.2 Watts | 1C / 2T | No | No | Launched | |
| Intel® Atom™ Processor Z510 (512K Cache, 1.10 GHz, 400 MHz FSB) | 2 Watts | 1C / 1T | No | No | Launched | |
| Intel® Atom™ Processor Z500 (512K Cache, 800 MHz, 400 MHz FSB) | 0.65 Watts | 1C / 2T | No | No | Launched | |
| Intel® Atom™ Processor N570 (1M Cache, 1.66 GHz) | 8.5 Watts | 2C / 4T | Launched | |||
| Intel® Atom™ Processor N550 (1M Cache, 1.50 GHz) | 8.5 Watts | 2C / 4T | No | Yes | No | Launched |
| Intel® Atom™ processor N475 (512K Cache, 1.83 GHz) | 6.5 Watts | 1C / 2T | No | Yes | No | Launched |
| Intel® Atom™ Processor N470 (512K Cache, 1.83 GHz) | 6.5 Watts | 1C / 2T | No | Yes | No | Launched |
| Intel® Atom™ processor N455 (512K Cache, 1.66 GHz) | 6.5 Watts | 1C / 2T | No | Yes | No | Launched |
| Intel® Atom™ Processor N450 (512K Cache, 1.66 GHz) | 5.5 Watts | 1C / 2T | No | Yes | No | Launched |
| Intel® Atom™ Processor N280 (512K Cache, 1.66 GHz, 667 MHz FSB) | 2.5 Watts | 1C / 2T | No | No | Launched | |
| Intel® Atom™ Processor N270 (512K Cache, 1.60 GHz, 533 MHz FSB) | 2.5 Watts | 1C / 2T | No | No | Launched | |
| Intel® Atom™ Processor E680T (512K Cache, 1.60 GHz) | 4.5 Watts | 1C / 2T | Yes | Yes | No | Launched |
| Intel® Atom™ Processor E680 (512K Cache, 1.60 GHz) | 4.5 Watts | 1C / 2T | Yes | Yes | No | Launched |
| Intel® Atom™ Processor E665CT (512K Cache, 1.3 GHz) | 7 Watts | 1C / 2T | Yes | Yes | Launched | |
| Intel® Atom™ Processor E665C (512K Cache, 1.3 GHz) | 7 Watts | 1C / 2T | Yes | Yes | Launched | |
| Intel® Atom™ Processor E660T (512K Cache, 1.30 GHz) | 3.6 Watts | 1C / 2T | Yes | Yes | No | Launched |
| Intel® Atom™ Processor E660 (512K Cache, 1.30 GHz) | 3.6 Watts | 1C / 2T | Yes | Yes | No | Launched |
| Intel® Atom™ Processor E645CT (512K Cache, 1.0 GHz) | 7 Watts | 1C / 2T | Yes | Yes | Launched | |
| Intel® Atom™ Processor E645C (512K Cache, 1.0 GHz) | 7 Watts | 1C / 2T | Yes | Yes | Launched | |
| Intel® Atom™ Processor E640T (512K Cache, 1.00 GHz) | 3.6 Watts | 1C / 2T | Yes | Yes | No | Launched |
| Intel® Atom™ Processor E640 (512K Cache, 1.00 GHz) | 3.6 Watts | 1C / 2T | Yes | Yes | No | Launched |
| Intel® Atom™ Processor E625CT (512K Cache, 600 MHz) | 7 Watts | 1C / 2T | Yes | Yes | Launched | |
| Intel® Atom™ Processor E625C (512K Cache, 600 MHz) | 7 Watts | 1C / 2T | Yes | Yes | Launched | |
| Intel® Atom™ Processor E620T (512K Cache, 600 MHz) | 3.3 Watts | 1C / 2T | Yes | Yes | No | Launched |
| Intel® Atom™ Processor E620 (512K Cache, 600 MHz) | 3.3 Watts | 1C / 2T | Yes | Yes | No | Launched |
| Intel® Atom™ processor D525 (1M Cache, 1.80 GHz) | 13 Watts | 2C / 4T | No | Yes | No | Launched |
| Intel® Atom™ Processor D510 (1M Cache, 1.66 GHz) | 13 Watts | 2C / 4T | No | Yes | No | Launched |
| Intel® Atom™ processor D425 (512K Cache, 1.80 GHz) | 10 Watts | 1C / 2T | No | Yes | No | Launched |
| Intel® Atom™ Processor D410 (512K Cache, 1.66 GHz) | 10 Watts | 1C / 2T | No | Yes | No | Launched |
| Intel® Atom™ Processor 330 (1M Cache, 1.60 GHz, 533 MHz FSB) | 8 Watts | 2C / 4T | No | No | End of Life | |
| Intel® Atom™ Processor 230 (512K Cache, 1.60 GHz, 533 MHz FSB) | 4 Watts | 1C / 2T | No | No | End of Life |
This is taken from the Intel Ark site.
Now based on the above table, the decision making process is slightly easier!
Subscribe to:
Posts (Atom)
loading..