Wednesday, November 23, 2011

java.lang.IllegalStateException: "Workbench has not been created yet"

I’ve been working with OSGi for quite awhile and have faced a problem "Workbench has not been createt yet" issues. I was getting this error, When i was trying to run OSGI plugin from Eclipse and I guess many of you must have face this problem. So i am writing a little bit about how to resolve this issue so others don’t repeat the same mistakes.

From a good article on eclipsezone:

java.lang.IllegalStateException: Workbench has not been created yet

This usually comes when someone tries to run a Java application against an OSGi bundle with java -classpath .... . It really means that the workbench plug-in hasn't started yet, and so calls to getWorkbench() fail. This is essentially a race condition, and can be solved by either expressing an explicit dependency on that bundle or bumping up that bundle to a higher start level than the workbench. Generally not seen, but if it is, that's what's happening.

Now to set the bundle to a higher start level than the workbench.
Select your manifest.mf, right-click, select Run As-> Run Configuration. Create a OSGi Framework launch configuration. Deselect all bundles except your bundle. Change the default set level to higher level and Press then "Add Required bundles"
Run this configuration. This should give you the correct output.

If you still get the same error ,then you can do
1. Add the -clean to the program Arguments.i,e(Run Configuration->OSGI framework->Arguments ->program Arguments)
                                           OR (Recommended 1 if failed then try 2)
2. Delete the .metadata folder which is created by default in Eclipse Workspace but before that please take the backup..:)




Hope its gonna work for you guys too..Feel free to comment.



Monday, October 31, 2011

Downloading and installing cURL on windows 7

cURL is a command-line tool. This means it is run from the command prompt (in Windows) or terminal (in Linux or OSX) and its results are displayed in the terminal window. There is no graphical interface. So in order to use cURL, you first have to open a command-line window.


To setup cURL:
  1. Download and unzip 64-bit cURL with SSL: http://curl.download.nextag.com/download/curl-7.21.7-win64-ssl-sspi.zip
  2. Copy the curl.exe file into your Windows PATH folder. By default, this is C:\Windows\System32.
  3. Download and install the Visual Studio 2010 C++ Runtime Redistributable 64 bit here: http://www.microsoft.com/download/en/details.aspx?id=13523
  4. Download the latest bundle of Certficate Authority Public Keys from http://curl.haxx.se/ca/cacert.pem
  5. Rename this file from cacert.pem to curl-ca-bundle.crt.
  6. Move this file into your Windows PATH folder. By default, this is C:\\Windows\System32.
Run cmd.exe to open your command prompt.
  1. type curl  http://www.google.com
  2. type curl  https://www.google.com
For both commands, you should see a couple pages of the HTML source code. If you see this, cURL is up and running!

Thursday, October 27, 2011

How to install Subversion,Google App Engine,Android with Eclipse.


This is tutorial assumes you already have Eclipse installed.

You can install the any plugin for Eclipse using the Software Update feature of Eclipse.
To install the plugin, using Eclipse:
Select the Help menu > Install New Software....
In the Work with text box, enter:


For Subversion:
http://subclipse.tigris.org/update_1.0.x

For Android:
https://dl-ssl.google.com/android/eclipse/

For Google App Engine:

Eclipse 3.6 (Helios):
http://dl.google.com/eclipse/plugin/3.6
Eclipse 3.5 (Galileo): http://dl.google.com/eclipse/plugin/3.5
Eclipse 3.4 (Ganymede): http://dl.google.com/eclipse/plugin/3.4
Eclipse 3.3 (Europa): http://dl.google.com/eclipse/plugin/3.3

Click OK
In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
In the next window, you'll see a list of the tools to be downloaded. Click Next.
Read and accept the license agreements, then click Finish.
Note: If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
When the installation completes, restart Eclipse.

Additional Info:
Android
Subversion

Wednesday, September 28, 2011

How to set Java JDK environment path in Windows 7



There are two ways to do the thing but doing it with Command prompt would be the easiest way. To start with the Command prompt hit “cmd” in the search after clicking on start. Now enter the command
set path="PATHNAME";
eg: set path="c:\Program Files\Java\JDK\bin";
and hit enter it will set your path automatically. Now you are ready to run your first Java program.

Saturday, July 16, 2011

MyAppSharer:An easy way to share apps with friends




Do you have friends that are constantly bothering you to “send them that app you used last week”? Tired of trying to hold hands while sending them to the Market? Well, thankfully, that painful part of your Android know how may be coming to an end, thanks to an awesome new app: MyAppSharer.

The app allows you to not only send them a direct Market link, but also to send them the APK directly via bluetooth, what's app, email, dropbox, SMS or QR code – which has the potential to be wonderful for either pulled apps or apps in development. If you want to get your hands on MyAppSharer, it’s a free download via the market link below. Be sure to check it out and sound off with your reviews in the comments!


                                                           Market Link

Android Interview Question

HI, these are the few Android questions that was asked during my interview and some basic questions too that you have to know before going to any interview, I am sharing with you guys. Hope It would help you in your interview too... 
It is impossible for me to give every and each answer over here,but yes if you are not getting any answer from anywhere then just let me know...:)

1) What is Android?

2) Features and Architecture of Android?

3) What is Android Market?

4) What is ADT, AVD, DVM, DDMS, Logcat?

5) Anatomy of an Android Application?

6) What are the basic Components in Android?

7) Describe the .apk format?

8) What is an action, resources.

9) How is nine-patch image different from a regular bitmap?

10) What are the dialog boxes that are supported in android? Explain.

11) What languages does Android support for application development?

12) What is the use of AndroidManifest.xml file in Android Application and the content too?

13) Difference between the android: versionCode and android: versionName Attributes in the AndroidManifest.xml file?

14) What is Activity, Intent, intent-filter ,stickyintent and PendingIntent ?

15) Life Cycle of an Activity?

16) How to Link Activities with Intents?

17) Difference between Toast and NotificationManager class?

18) Passing data to an Activity (Use of Bundle Object).

19) Which event is always called when you killed or sent an activity to background?(onPause() event)

20) View and ViewGroups.

21) What are all the ViewGroups supported by Android and the difference between them?

22) Screen Orientations(portrait and landscape) and techniques to handle changes in Orientation(Anchoring and Resizing and repositioning).

23) Units of Measurement (dp,sp,pt,px),160dp=1 inch

24) Difference between the dp and px unit?

25) Why is AbsoluteLayout not recommended for use?

26) Name the three events you can override to save an activity’s State.

27) Different types of menus supported by Android and the method name you need to override while implementing in your activity

28) Name the three basic ways of persisting data in your Android Application.

29) Sharing data in Android(Content Provider).

30) Difference between geocoding and reverse geocoding

31) What is Service?

32) How an activity and a service communicate?

Monday, July 4, 2011

Apache Ant - Tutorial

Introduction:
Ant (originally an acronym for Another Neat Tool), is a build tool with special support for the Java programming language but can be used for just about everything.Ant is platform-independent; it is written purely in Java. Ant is particularly good at automating complicated repetitive tasks e.g. compiling source code, running software tests, creating jar files, javadocs, etc. and thus is well suited for automating standardised build processes.
A build process typically includes:
     -the compilation of the Java source code into Java bytecode
     -creation of the .jar file for the distribution of the code
     -creation of the Javadoc documentation
Ant accepts instructions in the form of XML documents("build.xml") thus is extensible and easy to maintain.

Installation:

Linux (Ubuntu / Debian)

On Debian /Ubuntu use "apt-get install ant" to install it.

Windows
Download Apache Ant from http://ant.apache.org/ .
Extract the zip file into a directory structure of your choice. Set the "ANT_HOME" environment variable to this location and include the "ANT_HOME/bin" directory in your path.
Make sure that also the JAVA_HOME environment variable is set to the JDK. This is required for running Ant.
Check your installation by opening a command line and typing "ant -version" into the commend line. The system should find the command ant and show the version number of your installed ant.
                                                                     OR
The documents entitled Configuring A Windows Working Environment andConfiguring A Unix Working Environment are of use to people who need to know more.

Basics:
A simple Ant example is shown below followed by a set of instructions indicating how to use Ant.

<?xml version="1.0"?>  
<project name="test" default="compile" basedir=".">  

        <property name="src" value="."/>  
        <property name="build" value="build"/>

        <target name="init">  
                <mkdir dir="${build}"/> 
        </target>

        <target name="compile" depends="init">  
                 <!-- Compile the java code -->

                 <javac srcdir="${src}" destdir="${build}"/>   
         </target> 
</project>

1) The document begins with an XML declaration which specifies which version of XML is in use.

2) The root element of an Ant build file is the project element, it has three attributes.
  • name: The name of the project, it can be any combination of alphanumeric characters that constitute valid XML.
  • default: The default target to use when no target is specified, out of these three attributes default is the only required attribute.
  • basedir: The base directory from which any relative directories used within the Ant build file are referenced from. If this is omitted the parent directory of the build file will be used.
3) The property element allows the declaration of properties which are like user-definable variables available for use within an Ant build file. The name attribute specifies the name of the property and the value attribute specifies the desired value of the property. 

4) The target element is used as a wrapper for a sequences of actions. A target has a name, so that it can be referenced from elsewhere, either externally from the command line, or internally via the depends keyword, or through a direct call. The target in the example is called "init" (initiate), it makes a directory using the mkdir element with the name specified by the build property

5) depends allows one to specify other targets that must be executed prior to the execution of this target. In the listing abovedepends="init" is used to indicate that the compile target requires that the target named init be executed prior to executing the body of compile.

6) The example above causes javac to be executed, compiling all the.java files in the directory specified by the src property and placing the resultant .class files in the directory specified by the build property.

Example:
Copy the source code into a text editor and save the file as build.xml.Create a test directory and place the file in it. Create some arbitrary .javafile and place it in the same directory as build.xml. For convenience, here is an example .java file: test.java. Place the java file in the same directory asbuild.xml.

public class test { 
    public static void main(String[] args) { 
        System.out.println("Hello World!"); 
    }
}

Type the following at the commandline in the test directory:
ant -v
This will create a directory called build, compile test.java and place the .class file created in the build directory. The -v directs ant to be verbose. This verbosity causes the command to echo lots of information, information that is not really necessary for most normal purposes. Execute the command sequence again. An example output message is shown below:

[javac] test.java omitted as /path/to/temp/build/test.class is up todate

A nice feature of Ant is that by default, only those .java input files that have a more recent timestamp than their corresponding .class output files will be compiled.

For more info:

How TOPT Works: Generating OTPs Without Internet Connection

Introduction Have you ever wondered how authentication apps like RSA Authenticator generate One-Time Passwords (OTPs) without requiring an i...