Showing posts with label Open Source. Show all posts
Showing posts with label Open Source. Show all posts

Friday, September 26, 2014

Android Library Project and its usage

"Android Library projects contain shareable Android source code and resources that you can reference in Android projects. This is useful when you have common code that you want to reuse. Library projects cannot be installed onto a device, however, they are pulled into the .apk file at build time." 

When creating a new Android project you can mark a project as ‘Library’ project. This will create a project that can be shared/used in multiple projects. You cannot run/install the library project stand alone instead you have to reuse it in Android project.

How to mark a project as library:


Create a new Android project that will use the library project. Library project can be added as reference as follows:
  • Android Project > Properties > Android (left option) > Library (bottom right pane) > Add

  
                       

Click ‘Apply’ > ‘OK’

  • To use the library class activities in android project, 'import' the library references where ever you are using library files.
  • To launch the library activity you should have that activity listed in your Android project 'AndroidManifest.xml'.
  • Don’t make files (Layouts, Classes, XML’s) with the same name in main and library projects. This can cause problems at run time. What I have noticed is that if you have same name layouts in both projects the library layout got overridden and parent layout will be used.


rizzz86

Friday, May 30, 2014

Manipulating PDF document using iText library

There are several libraries that can be used to manipulate a PDF document like PDFBox, iText, PDFClows etc. I also have to do some PDF manipulation stuff and I decided to go with iText. I choose iText because it supports low level PDF manipulation, its community is very strong, lots of helping hands are available and it is also open source and available in both Java and C#.

iText allows you to create a PDF doument, add content in it, update content and save it. I have tried following basic features so far and found it really interesting:

  • With low level support one can add a text chunk, paragraph, phrase, link, chapter, section, image, set text color and other attributes into the document. 
  • You can also create a table/grid inside a PDF document and play with each cell of the table.
  • It is also easy to read an existing PDF document. You can retrieve existing information related to document and pages.
  • Using iText one can also fill up an empty PDF template.
  • It allows to set javascript in a PDF document to make a document interactive. Document can be also be navigated to a particular page. Creating bookmarks, annotations and triggering javascirpt from a button can also be done using iText.
  • Document can also be password encrypted to allow/disallow certain actions that can be done the document.
  • Whole PDF document can also be signed using a certificate to make the document secure.
There is also a book on how to play with PDFs using iText in Action. He is the author of iText in Action and is very supportive on stackoverflow. I also have some questions regarding iText on stackoverflow on this link.

rizzz86

Saturday, May 12, 2012

Installing DBDesigner 4 on Ubuntu

The only way I found to install DBDesigner 4 on Ubuntu is as follows:
  • Download the *.rpm file of DBDesigner.
  • Download the library package and extract it using:
tar xzvf kylixlibs3-borqt-3.0-2.tar.gz
  • After extracting it do the following:
sudo cp kylixlibs3-borqt/libborqt-6.9.0-qt2.3.so /lib/libborqt-6.9-qt2.3.so

Now your DBDesigner will be working, the executable file DBDesigner4 can be found at /opt/DBDesigner.

Found the solution on the following link.

rizzz86

Saturday, May 5, 2012

Installing Adobe Flash Plugin on Ubuntu

Installing Adobe Flash Plugin on latest versions of Ubuntu (11 +) is straight forward and can easily be done by directly search and install from Ubuntu Software Center.

The problem comes when you are using the old versions of Ubuntu. Yesterday I have to install Ubuntu 9.10 on my system and got the problem of installing flash player plugin. After some searching I found the solution that requires enabling of repositories. Step by step solution is as follows:

  • Go to "System > Administration > Software Sources" from the menu.
  • Click "Other Software" tab and check the two options that represents the repositories. Selecting those repositories allows Ubuntu to download other softwares that includes adobe flash plugin as well.
  • Go to  "System > Administration > Synaptic Package Manager" and search for 'adobe flash plugin'. It will give the package to install, you just need to select that package and click the 'Apply' button on the top.

Now you can run flash videos/games on your system.

rizzz86

Saturday, October 15, 2011

My Experience of Installing MongoDB on Ubuntu

In my last post I have write some very basic and initial points related to MongoDB. That was my initial observation of what MongoDB is and what are its basic features.

This article does not contains the detailed step by step tutorial of how to install MongoDB on Ubuntu. There are already lots of articles available on the installation of MongoDB on Ubuntu &Windows operating systems. In this post I am going to write my experience of Installing MongoDB on Ubuntu.

There are two common ways of installing any kind of software on Ubuntu. One is by using the "Ubuntu Software Center" and other is to download the package and install it manually. Option one is commonly used by users as it is very simple and it automatically download and install the target software on Ubuntu. In the case of MongoDB both option can be used for installation.

For testing purpose I have installed MongoDB using the Software Center (you can also use apt-get command that also download and install package from Software Center). Initially it works good by using it from terminal. I can able to start and stop MongoDB and execute different types of queries. The problem begins when I try to use MongoDB programmaticaly. I cannot able to connect with MongoDB using Java and Eclipse IDE even MongoDB is running and can be used from terminal. So, I have removed all the packages of MongoDB and install it manually. After that I am able to use it via terminal as well as programmatically.

This seems to be something related to version issue as also mentioned on this link. If someone knows what is the actual reason of this different behavior on different installation options do comment here. This is what I have experienced when installing and using MongoDB on Ubuntu.

rizzz86

Sunday, October 9, 2011

MongoDB: {name:"mongo", type:"DB"}

“MongoDB” as the name suggest, is a database that can be used to store data and apply other operations on the data later on. It is not a relational database like (MySQL, Oracle, MSSQL etc), but it provides all the basic operations that eases developer’s life in playing with the stored content. The name is a bit funny for me when I first heard it, but really it is built on some serious concept that opens number of questions of something alternative of relational databases. The concept is of NoSql / non-relational database.

MongoDB (from "humongous") is a scalable, high-performance, open source, document-oriented database. Written in C++

RDBMS has ruled the database world alone for a long time and always remains the only option for most of the software industry to go for it as their first option. Yes, lots of questions are there to choose which RDBMS to use and how the data will be structured within it. With some powerful concept of querying, maintain the integrity, indexing of data etc within RDBMS how come MongoDB’s concept will compete with it? What is the concept on which MongoDB is built? Is MongoDB fully replaceable to RDBMS? Are there other databases built on the same concept? Many more questions are there in this debate, so just have a look how MongoDB is different from relational databases.

MongoDB store data in documents. Yes, a document that have key-value pair. There is a predefined structure of MongoDB that starts with Database -> Collections -> Documents & -> Fields. So there is not any brainstorming sessions on how to structure our data. Just answer “How many collections do we have, and what are they? “.

One of the most important features of MongoDB is that it provided Indexing on data. This feature makes it different from other No SQL databases. It also support to query data from database. 

 If you're moving to MongoDB from a relational database, you'll find that many SQL queries translate easily to MongoDB's document-based query language. 

Other important features include Replication, Auto-Sharding, Batch Processing etc. Detail of each feature will be part of other posts as soon as I explore them and create some examples.


rizzz86


 

Wednesday, January 12, 2011

MD5 Hashing in J2ME

MD5 (Message Digest) is a hashing algorithm that can be used to ensure data integrity, save and protect passwords/codes, generate unique keys of limited length against a long literal etc. It takes input as String and generates the Hash of that string.

In JAVA there is a built-in MD5 support in its Standard Edition (J2SE). But if we talk about its Micro Edition (J2ME) their is no support for MD5. The package of JAVA Standard Edition can also be used in Micro Edition if and only if the platform supports the SATSA-Crypto Optional Package (How to know that your platform supports SATSA-Crypto).

I have found and tested the Third-Party implementation that can generate MD5 hash and can be used in JAVA Micro Edition. You can get the MD5 source files from here.

rizzz86

Wednesday, December 29, 2010

J2ME Default Emulator without asking for Permission

While running J2ME project with Default Emulator it will ask for Permissions in case of File Read/Write, HTTP Connectivity etc. To get rid of this Permission on every access you have to change the Security options of Emulator. In my case I am using NetBeans IDE, so to change these options I will go through following steps:
  1. Open Project Properties
  2. Click on Manage Emulators Button
  3. Go to Tools & Extension Tab and Click Open Preferences Option
  4. On Preferences Window click on Security option
  5. Select Security Policy to 'JTWI'
  6. Select Security Domain as 'trusted'
  7. Now run the project it will not ask for access Permissions

 rizzz86

Friday, September 10, 2010

Unit Testing for J2ME - JMUnit

In professional development environment it is a common practice to create Unit Tests. On Java platform there are lots of research and development done on Unit Tests for Enterprise Edition. As far as Java Micro Edition is concerned one of the framework available is JMUnit.

Creating and executing a test case using jmunit is quite simple and can be done without wasting much time to explore it. Following steps will guide you how to work with jmunit:

  •  In your mobile application right click on package (where you want to create a unit test) and select option 'New > Empty JMUnit Test'.
  • It will create a unit test class for you that will look like this:
    /*
     * ABCTest.java
     * JMUnit based test
     *
     */
    
    package hello;
    
    
    import jmunit.framework.cldc10.*;
    
    /**
     * @author rizwan
     */
    public class ABCTest extends TestCase {
        
        public ABCTest() {
            //The first parameter of inherited constructor is the number of test cases
            super(0,"ABCTest");
        }            
    
        public void test(int testNumber) throws Throwable {
        }    
    }  

    • Next you will create a test method in same class and call it in test() using switch cases.
    • Total count of test cases will also be mentioned in unit class constructor.
    • Now the code will look like this:

    /*
     * ABCTest.java
     * JMUnit based test
     *
     */
    
    package hello;
    
    
    import jmunit.framework.cldc10.*;
    
    /**
     * @author rizwan
     */
    public class ABCTest extends TestCase {
        
        public ABCTest() {
            //The first parameter of inherited constructor is the number of test cases
            super(1,"ABCTest");
        }            
    
        public void test(int testNumber) throws Throwable {
            switch(testNumber){
                case 0: 
                    testOne();
                    break;
            }
        }    
    
        private void testOne() throws Exception{
            String tmp = "Hello Rizwan";
            assertEquals(tmp, "Hello Rizwan");
        }
    } 

    • After that you have to mention 'ABCTest' as your Midlet.
    • Go into 'project properties > Application Descriptor > MIDlets' and define unit test name and package here.
    • Run application and you will also get Test option on screen:  
    • Test the project and it will show you the results




    Your mobile test case is ready !

    rizzz86

    Saturday, September 4, 2010

    Open Transport Tycoon Deluxe (TTD)

    TTD is one of my most favorite games that I have played and when I saw the 'Open' with it, I was really excited to install it on my Ubuntu OS.

    The installation of Open TTD is difficult and you need to be a bit keera of shell scripting to do this job. I have followed all the steps on this link and managed to install OTTD successfully. After completing installation and launching the game I was really amazed by watching the same TTD main screen as what I was playing on my 'Windows OS' four years back.


    The game is upgraded now and contains four different types of maps with each map containing different industries, disasters, vehicles etc. Maps are also really interesting with environment like a Desert area map, Snow area map, Toyland area map and a default one as well. I have some getty images of the game that are as follows:


    All TTD lovers do enjoy this on your Linux OS.

    rizzz86

    Friday, July 9, 2010

    MySQL Import/Export Commands

    Importing and Exporting through commands for mysql:

    Import File into Mysql:
    • mysql -ppassword -hlocalhost schemaname < /filePath/file.sql
    Export Mysql Schema in File:
    • mysqldump -uusername -ppassword database_name > dump.sql
    • mysqldump -uusername -ppassword -no-data database_name > dump.sql

    rizzz86

    Thursday, April 22, 2010

    Maven j2me-Archetype

    I am using Netbeans6.7 for mobile project development and want to make that project a 'maven project'. I have maven configured on my machine.

    To make maven based j2me project I have created a new project from File > New Project > Maven > Maven Project > j2me Archetype (2.0.4). The project created successfully and showing the properties of maven as well . . .  BUT !!

    I cannot able to view the properties of mobile project (i.e. Platform Type, Device Profile and Configuration, Midlet Information etc). To execute that project it requires a class with main() method. So I have posted all that on forum and finally got the following answer:

    j2me development is not supported for maven projects in netbeans :(

    rizzz86

    Thursday, April 15, 2010

    JSON source for J2ME (mobile applications)


    Javascript Object Notation (JSON) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. I am trying to use it in for mobile application development.

    Today I was looking for a JSON source code for Java Micro Edition (J2ME). After lots of googling I have found it from the following link:


    https://meapplicationdevelopers.dev.java.net/source/browse/meapplicationdevelopers/demobox/mobileajax/lib/json/src/org/json/me/



    rizzz86

    Wednesday, April 7, 2010

    Share Common Code Between J2ME and J2SE Project -- Problem/Solution


    Statement:

    If you are creating a client/server project on Java, where client is a mobile device and server is a web application. Also if there is a common code between client and server then where do you place that common code ?

    I also faces the same and go through the following phases before deciding what to do. The two points that came in mind right away are:

    • Create a J2SE Project and place common code there. Make your client and server project dependant on that common project.
    • Create a J2ME Project and place common code there. Make your client and server project dependant on that common project.

    First I have created J2SE as a Common Project:

    When I execute the client (J2ME) project with a dependency of common project (J2SE), I got the following error:

    Running with storage root DefaultColorPhone
    Method............: 100d2aa8 'com/sun/midp/midlet/MIDletState.createMIDlet (stat
    ic)'
    Stack Chunk.......: e58cd4
    Frame Pointer.....: e58d30
    Current IP........: 10128592 = 10128584 + offset 14
    Previous Frame....: e58cf4
    Previous IP.......: 1012052b (offset 22)
    Frame size........: 8 (1 arguments, 7 local variables)
    Argument[0].......: e59a9c
    Local[1]..........: 0
    Local[2]..........: e58cf4
    Local[3]..........: e68858
    Local[4]..........: e58d08
    Local[5]..........: 100dcdd0
    Local[6]..........: e58cd4
    Local[7]..........: 1015f0a0
    Operand[1]........: e59a9c
    
    Method............: 100cd0e4 'com/sun/midp/midlet/Selector.run (virtual)'
    Stack Chunk.......: e58cd4
    Frame Pointer.....: e58cf4
    Current IP........: 1012052b = 10120515 + offset 22
    Previous Frame....: 0
    Previous IP.......: 1
    Frame size........: 6 (1 arguments, 5 local variables)
    Argument[0].......: e59d10
    Local[1]..........: e68a68
    Local[2]..........: e59a9c
    Local[3]..........: 0
    Local[4]..........: 0
    Local[5]..........: 0
    Operand[1]........: e68a68
    
    VM status:
    Instruction pointer.: 10128592 (offset within invoking method: 14)
    Next instruction....: 0x4c
    Frame pointer.......: e58d30
    Local pointer.......: e58d10
    Stack size..........: 128; sp: e58d48; ranges: e58cdc-e58edc;
    Contents of the current stack frame:
    e58d10: e59a9c (lp)
    e58d14: 0
    e58d18: e58cf4
    e58d1c: e68858
    e58d20: e58d08
    e58d24: 100dcdd0
    e58d28: e58cd4
    e58d2c: 1015f0a0
    e58d30: e58cf4 (fp)
    e58d34: 1012052b
    e58d38: e58d0c
    e58d3c: 100d2aa8
    e58d40: e58cd4
    e58d44: 0 (end of frame)
    e58d48: e59a9c (sp)
    Execution stack contains 112 items:
    e59d10
    e68a68
    e59a9c
    0
    0
    0
    0
    1
    e58cd8
    100cd0e4
    e58cd4
    0
    e68a68
    e59a9c
    0
    e58cf4
    e68858
    e58d08
    100dcdd0
    e58cd4
    1015f0a0
    e58cf4
    1012052b
    e58d0c
    100d2aa8
    e58cd4
    0
    e59a9c
    
    Execution completed.
    429584 bytecodes executed
    10 thread switches
    486 classes in the system (including system classes)
    2380 dynamic objects allocated (72064 bytes)
    1 garbage collections (0 bytes collected)
    ALERT: java/lang/ClassFormatError: Bad version information.
    Execution completed.
    429584 bytecodes executed
    10 thread switches
    486 classes in the system (including system classes)
    2380 dynamic objects allocated (72064 bytes)
    1 garbage collections (0 bytes collected)
    


    After reading some forums I recompile my common project (J2SE) on jdk1.4 and add it as a dependency in client project (J2ME) again (previously I have compiled it on jdk1.5). This time the client (J2ME) executes and works successfully.


    ISSUES:

    In Java the development toolkit for mobile (J2ME) contains limited features as compared to the standard edition (J2SE). If you are creating your project on J2SE then you must not use any feature of J2SE in project that is not provided by J2ME (mobile edition have limited features).

    In jdk1.5 there are some major specification changes due to which it generates different byte-code number that results in "ALERT: java/lang/ClassFormatError: Bad version information". So you need to run/compile your common (J2SE) project on jdk1.3/1.4




    Next I have created J2ME as a Common Project:

    I am using Netbeans 6.7 for development, so I have created 'Java ME > Mobile Class Library' project for common code. The Mobile Class Library is a mobile project but does not contain any Midlets. It uses IDE-generated Ant build scripts and special tasks to pre-process, build, obfuscate, preverify, debug, run and depoly your library in JAVA ME Environment.

    I moved all my common code in this mobile project and then use it as a dependency for both client (J2ME) and server (J2SE) projects and it works properly for both editions. Doing this ensures the compatability of both versions because mobile edition features are already supported by standard edition. Also you will be free from jdk-versioning issue that was faced in previously.

    Conclusion:
    So create 3 different projects, one is a client (J2ME), another is a server (J2SE) and a common project (J2ME) that will be used by client and server.



    rizzz86

    Monday, April 5, 2010

    Share Folder Between Ubuntu (host) and WinXP (guest) on Virtual Box

    Following steps helps me to successfully share folders between host and guest:

    • On VBox (Windows) add a shared folder from Devices > Shared Folders. Write the folder name here as well.
    • Now in guest (WinXP), use the "Add Network Place Wizard" in Windows. Follow the wizard and look for you shared folder, add it and you're done.

    rizzz86

    Wednesday, March 3, 2010

    Installing Virtual Box Guest Addition (Problem/Solution)

    I have a VirtualBox-OSE installed on my Ubuntu from which I am running WindowsXP. The 'OSE' type of VBox that was installed on my machine is not much rich i.e. no pointer sharing between operating systems, no full screen display for Virtual Box's OS etc. I need to overcome these problems to make my working more easy.

    After reading comments on different forums, I conclude that I need a 'Guest Addition' of VBox. So I have started to install the Guest Addition for my VirtualBox-OSE. I follow the same steps as mentioned on forums to install the guest version but always gets the following error messages:

    Could not find the VirtualBox Guest Additions CD image file /usr/share/virtualbox/VBoxGuestAdditions.iso or /usr/lib/virtualbox/additions/VBoxGuestAdditions.iso. (i.e. it cannot able to find 'VBoxGuestAdditions.iso' file) Do you want to download this CD image from the Internet? And then it returns 404 :s

    Now on one of the forum I found different information related to VirtualBox Editions: "There are two different Editions of VBox: PUEL and OSE. PUEL has a lot richer functionality but is available from proprietory Sun repositories. The GA are bundled this as an ISO. In the OSE version the GA are typically available as a separate virtualbox-ose-modules package."

    The next thing that I have done is to uninstall the VirtualBox-OSE right away. I have downloaded the PUEL Edition of VBox and installed it. Now I have got the PUEL Edition, I can install the 'Guest Addition' on this VBox. The missing file 'VBoxGuestAdditions.iso' is now available in the folder. I doesn't have any issued in installing the guest addition after that. And finally have some rich features in my VBox.



    Small Screen



    Full Display


    rizzz86

    Tuesday, January 26, 2010

    Internet Explorer for Linux - (ie4linux)


    Following Steps to be done for IE installation on LINUX:



    Command 1:
    wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz
    Command 2: tar zxvf ies4linux-latest.tar.gz
    Command 3: cd ies4linux-*
    Command 4: ./ies4linux

    Following screen will appear on executing command-4:



    Click on Advance Button to set Paths. Also check on the 7.0 checkbox to get IExplorer7.




    After completion of process go to your specified path. You will find ies4linux-ie6.desktop and ies4linux-ie7.desktop files. Double click on any one to start IE on Linux.





    NOTE:
    =====

    Executing Command-4 gives me the following error:

    "IEs4Linux 2 is developed to be used with recent Wine versions (0.9.x). It seems that you are using an old version. It's recommended that you update your wine to the latest version (Go to: winehq.com).
    You need to install cabextract first!
    Download it here: http://www.kyz.uklinux.net/cabextract.php"


    Actually here the error is not correct because i do have latest version of Wine but doesn't have cabextract.

    You can install Wine easily from Add/Remove Applications.
    If cabextract is not Installed go through the following steps:

    Command 5: wget http://www.cabextract.org.uk/cabextract-1.2.tar.gz
    Command 6: tar -zxvf cabextract-1.2.tar.gz
    Command 7: cd cabextract-1.2
    Command 8: ./configure
    Command 9: make
    Command 10: make install



    rizzz86

    Friday, November 6, 2009

    DBDesigner 4 (ERD Generation Tools)

    I have used DBDesigner-4 to model my ERD diagram on a Linux operating system. The good thing about DBDesigner is that it is opensource and can be used on both Windows and Linux platforms.

    DBDesigner 4 is a visual database design system that integrates database design, modeling, creation and maintenance into a single, seamless environment. It combines professional features and a clear and simple user interface to offer the most efficient way to handle your databases. DBDesigner 4 is developed and optimized for the open source MySQL-Database to support MySQL users with a powerful and free available design tool. All MySQL specific features have been built in to offer the most convenient way to design and keep control of your MySQL-Databases.

    DBDesigner provides number of features while modeling an ERD including:
    • drop drag foreign key field creation,
    • "regions" to group similar tables,
    • exporting ERD in image format,
    • generate SQL scripts,
    • connect and open tables directly from database (i cannot able to perform that one),
    • view ERD in query mode etc..

    After designing full fledged ERD, I have also come up with some cons and limitations of this tool. Some of them are as follows:
    • one of the biggest limitation is that it is developed specifincally for MySQL database. Which means that you cannot switch between databases by only using this tool.
    • i haven't found in the whole tool that 'How to add a CONSTRAINT on any table ;('. I have to add all the constraints manually (in the script) at the end of ERD.
    • why can,t I change the name of the foreign key in any table ;-?. The name of foreign is fixed (i.e. tablename_id) and cannot be edited.
    • no type of comparisons at any level.
    Overall a mediocre tool for MySQL based ERD modeling. I will recommend to use this tool if you are using myslq and your application scope is also not huge.


    rizzz86