Chirag Jain

I am working as a java developer in BNP Paribas,Mumbai,India. I have interest in Java technologies and Database.

Homepage: https://techwithcj.wordpress.com/

Blackberry Code Signing Hangs or Taking too long: Java 7 Issue

I am working on a blackberry app for OS 7. I had received keys from Blackberry and tried to sign my app using Eclipse Signature tool in Blackberry Eclipse plugin. But whenever I started signing the app, it signed some of the .cod files and then hanged. Even after waiting for hours, it kept showing “Receiving Response” for some .cod files, specially for RRT key file. After searching on net , I found that it was because of Java 7.

Though I have not referred Java 7 anywhere in Eclipse, it was using it when signing the code. because by default, my system path was set to Java 7, though Java 6 was also installed. I uninstalled Java 7 and then system was set to using Java 6 by default. After that, I signed the code and Wow! it was completed at the blink of the eye.

So Blackberry does not support Java 7 . You need to install Java 6 and set its path in System Environment variables so that code signing process works well.

PS: My system is on Windows 7, 64 bit. I am developing app using Blackberry JRE 5.0.0

Leave a comment

Difference in App and Web Server

Here is a very good article describing difference between application server and web server.

In another article, we can see what differentiates a full fledged Java EE application from a Java Web application.

Leave a comment

Method Overloading Ambiguity Problem

While going through an article about method overriding in OOP, I stumbled upon an ambiguity problem in overriding.

Here is the java code I wrote to test it:

public class OverLoadingTest {

static void testOverload(int i,double d) {
System.out.println("testOverload 1: int, double");
}

static void testOverload(double d,int i) {
System.out.println("testOverload 2: double,int");
}

public static void main(String[] args) {

testOverload(2,3.5);
testOverload(2.5,3);
testOverload(2,3); // Compilation error:  The method testOverload(int, double) is ambiguous for the type OverLoadingTest
  }
}

In the third call testOverload(2,3), there will be a compilation error, because:

First argument 2 is int, so java compiler will decide to call the method testOverload(int,double) because its first argument is int, so it is better match than .testOverload(double,int)

Second argument 3 is also int, so java compiler will decide to call the method testOverload(double,int) because its second argument is int, so it is better match than testOverload(int,double)

As compiler will not be able to decide the right overloaded version for call, compilation error occurs.

Happy Coding !

Leave a comment

Enable/Disable Speakers/Headphones in Windows 7

Today I accidentally disabled my Windows 7 laptop speakers. I was installing Skype and testing it with headphones. I was getting the voice from other side from the laptop speakers, not through headphones. So I went to Control Panel–> Sound and disabled the speakers. So now only headphones were enabled, so the voice started coming through headphones. But now how to enable the speakers back? Now in Control Panel–> Sound, I was not getting speakers anywhere, so there was no way to enable them. Then when I googled it and found this article.

The solution was simple. In Control Panel–> Sound, in Playlist tab, Right Click and check Show Disabled Devices. Then select the disabled device, speakers in this case, go to Properties and there you can enable them. Hope this helps.

Happy Listening !

 

enable speakers in windows 7

,

6 Comments

toLowerCase() is Locale Based

I have found this very interesting and informative post for Java developers. Many Java developers may not know that toLowerCase() and toUpperCase() methods of java.lang.String class are Locale based. Have a look here at javadocs for these methods.

toLowerCase() internally calls toLowerCase(Locale locale). Same is the case for toUpperCase().

Leave a comment

Reading rss feed using java (JSP Taglib)

We can read RSS (Real Simple Syndication) feeds and publish them on our web page using JSP(Java Server Pages) tag library. Sun provides a rss taglib that can be used in JSP. It is extremely simple to use. You just need to have basic knowledge of JSP and HTML.

So, how to do that? First you need to download the tag library file (rssutils.tld, rssutils.jar) from Sun’s website. Here is the url to download it. Put the files rssutils.tld and rssutils.jar in WEB-INF/lib directory of your web application.
After that, choose a blog or website who publishes its rss feeds to users, and get the url of its rss feed. In below example, I have used the rss feed url of this blog. Please find the attached file here and save it with .jsp extension (rssTest.jsp)
You can use tag also to read content in a loop.
For a small tutorial on rss taglib, go here

To know what RSS is, go here

,

2 Comments

enum as a class

Here I have compared enum with a class. In java, enums are like classes. What I have done here is, if we have to write a class that works like en enum, how can we do it. Though it is not of practicle use,what I have tried is to make the concept clear about enums.By comparing enum with a class, we can understand how enums work.

Here DayEnum is a enum and DayClass is class for that enum.

enum DayEnum {
SUNDAY, MONDAY
}

class DayClass {
String value;
public DayClass (String str)
{
value=str;
}

static DayClass SUNDAY, MONDAY;
static
{
SUNDAY = new DayClass("SUNDAY");
MONDAY = new DayClass("MONDAY");
}
}

public class Test
{
public static void main(String args[])
{
DayClass dayClass = DayClass.SUNDAY;
DayEnum dayEnum = DayEnum.SUNDAY;
System.out.print("dayClass "+dayClass.value+" \n dayEnum "+dayEnum);
}
}

Here SUNDAY, MONDAY are similar to static objects of Day if Day were a class.

We use enum as:
DayEnum day = DayEnum.SUNDAY;

enums are like constants. To simulate that, I have used value in DayClass. So every object of DayClass has an integer value associated with it.

Leave a comment