Wednesday, December 18, 2013

Install Java on Linux


How to Install Java on Linux?


I have seen many posts where they explain how to install Java on Linux but none of them had clear instruction(They may be clear for experienced Linux user but not clear for a naive user). This is the reason why this post is coming out. Here I will explain how to install JDK(Oracle) on Linux system and also how to have multiple versions of Java on single linux machine. 

Installation instruction for JDK 7.0 and up is different compared to JDK 6.0 and below. So I will explain them separately. 

Installing JDK7.0 and up:

1) Download JDK from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html (.tar version)
2) Extract it and move it to /usr/lib/jvm(You can move it to any directory you want)
3) sudo gedit /etc/profile, add below lines
JAVA_HOME=/usr/lib/jvm/jdk1.7.0_35
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH

4) Check for java_home using -> echo $JAVA_HOME
5) Check for java version using -> java -version

Thats it. This will install java on your linux system. If it shows any problem then restart your system.

Installing JDK6.0 and below:


1) Download JDK from http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u45-oth-JPR
2) Change the directory where you want to install JDk. I am changing to /usr/lib/jvm.
cd /usr/lib/jvm
3) Copy the bin file to /usr/lib/jvm
4) Change the persmission of the  .bin file chmod +x 6u <version>-linux-x64.bin
5) Get the root access(Sudo su).  and then install the jdk using the following command ./jdk-6u35-linux-x64.bin 
6) sudo gedit /etc/profile, add below lines
JAVA_HOME=/usr/lib/jvm/jdk1.6.0_35
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH

7) Check for java_home using -> echo $JAVA_HOME
8) Check for java version using -> java -version


Having Multiple version on same machine

Installing multiple version of Java is nothing but doing installing jdk twice with the version that you want and setting up the Path and JAVA_HOME variables to the version that you want to use at that particular time. 

Ex: If you want to use jdk1.7.0_35 then in the   /etc/profile file, add the path to this folder.
and if you want to use jdk1.6.0_35 then in the   /etc/profile file, add the path to this folder.

This will inform your system to take the java version that you are suggesting.

I hope this post will help you in installing Java on Linux machine. Any comment or feedback or your experience will help me to learn more.

P.S: I have tested on Ubuntu and Linux Mint and guess must be working on other linux flavour  as well. 

Tags: Install Java on Linux, Install Java on Ubuntu, Install Java on Linux Mint, multiple version of java on same machine, install JDK 7 on linux, install jdk 6 on linux.

Sunday, December 1, 2013

Vasooli Manger - A Fund Manager

Vasooli Manager - A Fund Manager

I have created my first Android app and have uploaded it on Play store. Name of the app is Vasooli Manager (A fund Manager)


Everyday we spend most of our time managing out flow of our money, desperately try to fill our wallets back with it and keeping track of it becomes very crucial. Whether its our business accounts, travel funds or even pocket money, writing it down on those cramped patches in a torn out bit of paper or trying to store it in a remote corner our memory may not always be effective.To help in keeping trace of our funds, I have Made an Android Mobile Application called "Vasooli Manager".

  


Vasooli Manager is an intuitive, useful and simple to use Fund Manager on the Android Market and a handy tool for individuals. It helps you in tracing your debits and get hold of those who owe you your money and also generate a report of your transactions.Try it to see what it is.


Google Play Store URL : https://play.google.com/store/apps/details?id=com.pradeep.vasooliManager
Youtube URL : http://www.youtube.com/watch?v=t9tciAnwXTI

I appreciate for your time in reviewing the app.

Friday, August 16, 2013

Personal Launcher - A Parental Control cum personalized laucher

Personal Launcher

If you are someone like me who keep reading what Google is doing with Android then you must have read that they have introduced multiuser login system for Android tablets starting from Android 4.2. Nice concept that will allow parents to restrict there child from using limited apps, business owners can use it as a kiosks , anywhere where you want to control access.

Great.
But what about android 4.0 , 4.1 ? 

If you have tablet that comes under this range then you can use a launcher that works similar to what Android 4.3 does. 






A custom launcher for Android tablets that allows multiple users to create password-protected accounts. This handy app is designed to restrict access; the administrator decides which group/user can use which features and apps. They can also set time limits for particular users, deny them internet access etc.

The app also helps parents who wish they could control the amount of time their children spend on their Android tablets. Personal Launcher allows parents to create an account for their kids and set a limit on it. Their own (the parents') accounts can be password protected, keeping kids from entering them. Apart from limiting time, parents can also disallow kids from using certain applications and games, as well as the WiFi among other things. Seems like a good measure to tackle nomophobia. 

This app is ideal for tablets used by more than one person, parental control, businesses like restaurants, kiosks and internet centers.

Features


  • Default ‘Guest’ account. Sign out of your account before handing your tablet to others
  • Your kids addicted to games? Decide how many hours they can use the tablet for or disallow them from using certain apps
  • Customize user accounts by assigning a photo
  • Support for recovery password pin

Coming Soon
  • Launcher for Mobile phones
  • Custom profiles based on location such as ‘Home’, ‘Work’ etc
  • User based Wallpaper
  • More Profiles & Themes
      Login Screen where you see all the users and are password protected







Launcher Home Screen. Top right corner has two images , one will take you to the place where you control settings and the other is for logout.




This screen lets you create groups . Here you can enable Guest account by clicking checkbox.



Add, Edit or delete user here.



Give settings to the group.



Assign Apps and only those apps can be used by the members of this groups or user of this group.




You can download this superb and very handy app from here.

YouTube : http://www.youtube.com/watch?v=AMh08uIRQQ0
What do you think about this  Android Launcher? 


About Me


Hello. This is Pradeep Jain working as a Software Developer in an IT firm based in India and along with that I am working as a freelancer to help different clients all over world to implement their innovative Ideas.

I am specialist in Web application and Mobile application. I create web app using PHP, Java and mobile application for Android. If you think you have any breakthrough idea, which can be the unique and breath taking then feel free to discuss with me regarding that. I promise working with me will be great for both of us personally and professionally. I will help you in all ways to bring the Idea live and finish it before time.

This blog is mostly for those who like Android, who admire technology and who loves shayri. Read it and dont forget to share your views, criticism, and anything that you feel after reading this blog. Your views will help me to grow.

I am available at

Skype: pradeep145516 ,
Email Id: l.pradeep.jain@gmail.com
Linkedin : www.linkedin.com/profile/view?id=132230271

Thursday, May 23, 2013

Adding Sliding Menu In Android

Sliding menu has become a hit and we see almost all apps adopting this style. I will show you how to add it to your app.

I will use https://github.com/jfeinstein10/SlidingMenu library. Its very simple and straightforward to use.

Step 1) Download it and add it to your project as a library - Download it and import to eclipse. Right click your project . Properties ->Android -> Bottom there will be a button to add library. click on that and add it.

Step 2) Create a layout for sliding menu - Create an XML file in layout folder. Layout can have a list view or fragment or anything that you want.

 Step 3) Extend Sliding Activity - Go to your main Activity and instead of extending normal Activity Class, extend SlidingActivity.

Step 4) Set layout and few Properties - In onCreate Method add the layout for sliding area.


setBehindContentView(R.layout.your_sliding_layout) -> This will add layout.
SlidingMenu menu = getSlidingMenu() -> Get SlidingMenu Instance.
menu.setMode(SlidingMenu.LEFT) -> Add menu to left side.
...
You can refer to various properties on Github.

One more point.
If you want to add sliding menu along with ActionBar then their site had given tutorial how to do it. If you want Action Bar to be static and not move along with sliding menu then you can use  setSlidingActionBarEnabled(false).  This will keep it static.

Thanks for reading and do comment if you have anything to say or add.

Friday, March 8, 2013

Hiding and Showing System Bar(Status Bar + Navigation Bar) in Android Tablets using Android Source Code

After Searching on google for hours, I couln't find a single tutorial which described how to hide and show system bar in Android tablets.

System bar in Android Tablets is Status Bar + Navigation Bar.

Here I am not talking about hiding system bar for a short time and then showing it again when you touch the screen. I am talking about hiding the Bar permanently and showing it only when you want to.





For hiding the system bar temporarily and showing it again on touch you can use the following code

View v = findViewById(R.id.view_id);
v.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);


But this will show the System Bar when you touch the screen. What If you want to hide it permanently? Is it possible ? 

The answer is Yes. Read on to know how.

We cannot implement this functionality directly in our app because Android Source code doesn't allow us to do it. Then how? Guess?
Yes ! we will change the source code of Android and implement this functionality. This is the benefit of working on an Open Source Platform. You have the code and you can modify and play with it.

So lets start

Step 1: The most basic step , setting up Android Environment so that you can run the source code and debug it (if required). Follow this if you don't how to do it.

Step 2: Download the Android source code from  here and set up the environment as explained there. This is the official website of Android Source code. Download and set up the code. The demo which I will show in this post is on  Android_4.0.999. You might download a different version but not sure whether it will work on that. Warning :-  Android source code for the version Android_4.0.999 is 22.4 GB. And building for the first time will take 6 to 8 hours depending on your system capability.

Step 3: After building the source code first time, we are now ready to make changes to hide the  System Bar in Android Source code. I use eclipse as the IDE for editing and creating the Android application so all the instructions that will be shown here will be based on that. Search for the folder named SystemUI. Its in Android_4.0.999/frameworks/base/packages. Open this in eclipse as an existing project. It will show two projects. Select DreamsDockLauncher.

Step 4: Eclipse will show you many errors. Just Ignore them. SystemUI is dependent on many other projects which we have not included here and thats why its showing so many errors. Now go to src->com.android.systemui.statusbar.tablet->TabletStatusBarView.java.
This is the class which is creating and displaying system bar. Now we will modify it.

Step 5: In my implementation, my tablet is connected to a server and it will receive message from server saying whether I should I hide the bar or show it. The bar should be hidden when the tablet is restarted. TabletStatusBarView.java has a method called  addStatusBarWindow() . This will create and add Bar to WindowManager. We have to modify this method.

Make  WindowManager.LayoutParams lp as an Instance variable instead of a local variable.Then add the below code

   public  WindowManager.LayoutParams lp;

    private void addStatusBarWindow() {
        final View sb = makeStatusBarView();

         lp = new WindowManager.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.TYPE_NAVIGATION_BAR,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING
                    | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
                // We use a pixel format of RGB565 for the status bar to save memory bandwidth and
                // to ensure that the layer can be handled by HWComposer.  On some devices the
                // HWComposer is unable to handle SW-rendered RGBX_8888 layers.
                PixelFormat.RGB_565);

        // We explicitly leave FLAG_HARDWARE_ACCELERATED out of the flags.  The status bar occupies
        // very little screen real-estate and is updated fairly frequently.  By using CPU rendering
        // for the status bar, we prevent the GPU from having to wake up just to do these small
        // updates, which should help keep power consumption down.

        lp.gravity = getStatusBarGravity();
        lp.setTitle("SystemBar");
        lp.packageName = mContext.getPackageName();
        WindowManagerImpl.getDefault().addView(sb, lp);
        WindowManagerImpl.getDefault().removeView(sb);
    }

We will allow our method to add the view to WindowManager and then remove it.

Now if you build and run it in the emulator, System bar would be gone.

Step 6: Since you do not have a server side code, we will create a dummy app which will broadcast messages and SystemUI will listen for it. We will name the dummy app as TestingSystemBar. It will have two buttons Show System Bar and Hide System Bar.

Code for two buttons

public void showSystemBar(View v)
    {
        Intent intent=new Intent();
        intent.putExtra("type", "show");
        intent.setAction("CheckingNotificationMessageForSystemBar");
        sendBroadcast(intent);
    }
    public void hideSystemBar(View v)
    {
        Intent intent=new Intent();
        intent.putExtra("type", "hide");
        intent.setAction("CheckingNotificationMessageForSystemBar");
        sendBroadcast(intent);
    }

Step 7: We will create BroadcastReceiver in SystemUI. For more information on BroadCastReceiver you can see this and this.

Add this code in  TabletStatusBarView.java.

   
     public class HideSystemBar extends BroadcastReceiver {

        @Override
        public void onReceive(Context context, Intent intent) {
            Log.v("HideSystemBar", "Hiding system bar"+intent.getStringExtra("type"));
            if(intent.getStringExtra("type").equalsIgnoreCase("hide"))
            {
                Log.v("HideSystemBar", "Hiding system bar1");
                try
                {
                   WindowManagerImpl.getDefault().removeView(mStatusBarView);
                }
                catch(Exception e)
                {
                   
                }
               
            }
            else
            {
                try
                {
                    WindowManagerImpl.getDefault().addView(mStatusBarView, lp);
                }
                catch(Exception e)
                {
                   
                }
            }

        }

    }

You can catch the exception and do whatever you want to do with it.

Step 8: Register the BroadcastReceiver dynamically. Modify the code like this

protected void createAndAddWindows()
{
        addStatusBarWindow();
        addPanelWindows();
        mContext.registerReceiver(new HideSystemBar(),new IntentFilter("CheckingNotificationMessageForSystemBar"));
}

This will add register the BroadcastReceiver.

Done. Now run both the app in same emulator.

Note : To open a tablet emulator use this command


out/host/linux-x86/bin/emulator -sysdir out/target/product/generic/ -system out/target/product/generic/system.img -ramdisk out/target/product/generic/ramdisk.img -data out/target/product/generic/userdata.img -skindir "your sdk location"/android-sdk-linux/platforms/android-16/skins -skin WXGA800-7in -scale 0.7 -memory 512 -partition-size 1024

Thats it. Done. Keep playing with open source code to learn more. In my next post I will write about RecentApp option that you find in System Bar.

Was the post useful? Or any changes that you would suggest?