Monday, August 28, 2006

Does machine have JAVA

My friend can up with a curious problem.

To run an applet a prerequiste is to actually check whether JRE(or JVM) is actually present on the machine. Although applet inherits the intelligence to actually point the browser to the web location.

However if the application has to be in total control then how??????

In short for Non-IE browsers then navigator.mimeTypes gets the registry values for the installed runtimes.
But alas IE does not implement mimetypes. So an activeX document to implement the same.


Here is a small snippet of the code written in javascript.


if(navigator.mimeTypes) {
//For non-IE browsers
for (i=0; i < navigator.mimeTypes.length; i++) {
if( (navigator.mimeTypes[ i].type != null)
&& (navigator.mimeTypes[ i].type.indexOf(
"application/x-java-applet;jpi-version=1.5") != -1) ) {
pluginDetected = true;
break;
}

}
}
} else if (is_ie5up) {
var javaVersion;
var shell;
try {
// Create WSH(WindowsScriptHost) shell, available on Windows only
shell = new ActiveXObject("WScript.Shell");

if (shell != null) {
// Read JRE version from Window Registry
try {
javaVersion = shell.regRead("HKEY_LOCAL_MACHINE\\Software\\JavaSoft\\Java Runtime Environment\\CurrentVersion");
} catch(e) {
// handle exceptions raised by 'shell.regRead(...)' here
// so that the outer try-catch block would receive only
// exceptions raised by 'shell = new ActiveXObject(...)'
}
}
} catch(e) {
}
My friend can up with a curious problem.

To run an applet a prerequiste is to actually check whether JRE(or JVM) is actually present on the machine. Although applet inherits the intelligence to actually point the browser to the web location.

However if the application has to be in total control then how??????

In short for Non-IE browsers then navigator.mimeTypes gets the registry values for the installed runtimes.
But alas IE does not implement mimetypes. So an activeX document to implement the same.


Here is a small snippet of the code written in javascript.


if(navigator.mimeTypes) {
//For non-IE browsers
for (i=0; i < navigator.mimeTypes.length; i++) {
if( (navigator.mimeTypes[ i].type != null)
&& (navigator.mimeTypes[ i].type.indexOf(
"application/x-java-applet;jpi-version=1.5") != -1) ) {
pluginDetected = true;
break;
}

}
}
} else if (is_ie5up) {
var javaVersion;
var shell;
try {
// Create WSH(WindowsScriptHost) shell, available on Windows only
shell = new ActiveXObject("WScript.Shell");

if (shell != null) {
// Read JRE version from Window Registry
try {
javaVersion = shell.regRead("HKEY_LOCAL_MACHINE\\Software\\JavaSoft\\Java Runtime Environment\\CurrentVersion");
} catch(e) {
// handle exceptions raised by 'shell.regRead(...)' here
// so that the outer try-catch block would receive only
// exceptions raised by 'shell = new ActiveXObject(...)'
}
}
} catch(e) {
}

Thursday, August 17, 2006

Richard Stallman @IISc

Title: Free Software: current status and challenges

Time: 19 Aug (Sat) 11am
Place: Faculty Hall

Speaker: Richard Stallman,
Founder of GNU project and FSF (Free Software Foundation)


Abstract:
Richard Stallman will give a talk on free software and current status on
aspects such as GPLv3, DRM (digital rights mgmt), DMCA, etc.

Bio:
Richard Stallman is the founder of the GNU Project, launched in 1984 to
develop the free software operating system GNU. The name ``GNU'' is a
recursive acronym for ``GNU's Not Unix''.

Stallman graduated from Harvard in 1974 with a BA in physics. During his
college years, he also worked as a staff hacker at the MIT Artificial
Intelligence Lab, learning operating system development by doing it. He
wrote the first extensible Emacs text editor there in 1975. He also
developed the AI technique of dependency-directed backtracking, also
known as truth maintenance. In January 1984 he resigned from MIT to
start the GNU project.

Stallman received the Grace Hopper award for 1991 from the Association
for Computing Machinery, for his development of the first Emacs editor.
In 1990 he was awarded a Macarthur foundation fellowship, and in 1996 an
honorary doctorate from the Royal Institute of Technology in Sweden. In
1998 he received the Electronic Frontier Foundation's pioneer award
along with Linus Torvalds. In 1999 he received the Yuri Rubinski award.
In 2001 he received a second honorary doctorate, from the University of
Glasgow, and shared the Takeda award for social/economic betterment with
Torvalds and Ken Sakamura. In 2002 he was elected to the US National
Academy of Engineering, and in 2003 to the American Academy of Arts and
Sciences. In 2003 he was named an honorary professor of the Universidad
Nacional de Ingenieria in Peru, and received an honorary doctorate from
the Free University of Brussels. In 2004 he received an honorary
doctorate from the Universidad Nacional de Salta, in Argentina.

About GNU:

GNU is free software: everyone is free to copy it and redistribute it,
as well as to make changes either large or small. Non-free software
keeps users divided and helpless, forbidden to share it and unable to
change it. A free operating system is essential for people to be able to
use computers in freedom.

Today, Linux-based variants of the GNU system, based on the kernel Linux
developed by Linus Torvalds, are in widespread use. There are estimated
to be some 20 million users of GNU/Linux systems today.

Richard Stallman is the principal author of the GNU Compiler Collection,
a portable optimizing compiler which was designed to support diverse
architectures and multiple languages. The compiler now supports over 30
different architectures and 7 programming languages.

Stallman also wrote the GNU symbolic debugger (gdb), GNU Emacs, and
various other programs for the GNU operating system.

Monday, August 07, 2006

Is this methods fool proof?

Does this method make a valid check for even numbers?

public static boolean isEven(int i) {
return i % 2 == 1;
}

Wednesday, August 02, 2006

Nice Article on troublshooting

Check this out

I liked the following points discussed

1)Use of strings for printing the strings of printable characters in files.

2)Apt examples of gdb,strace & ldd

Also this very useful tip. I ran into this , for finding out what is used of "OR-ing" in javascript.

"Google normally removes common words like 'and', 'or', 'when' etc from the search patten. To forcefully include them in the search, use a '+' just before the word. ( +word_to_be_included)"