Saturday, August 23, 2014

Share Laptop Internet Connection With Android Device


Without using any software you can simply crate a wifi hotspot in Windows.

1. Open command prompt with administrator privileges. (Right click -> Run as administrator).

2. Enter following command to create the connection.
netsh wlan set hostednetwork mode=allow ssid=MyWifiName key=myPassword

Here you can give any values for 'ssid' and 'key'. ssid will be you wifi connection name and key will be the password.

3. Enter following command to start the network.
netsh wlan start hostednetwork

Make sure you have turn on wifi on your laptop. Otherwise you will be getting a message like following.
The hosted network couldn't be started.
A device attached to the system is not functioning.

When everything is properly configured, your command prompt would look like following.



4. Now open the "Network and Sharing Center" (Click internet connectivity icon on the task bar and open Network and Sharing Center or Go to control panel and click network and internet related options).
Click the "Change adapter setting" option in right hand-side of the window.
There you will see all your network connections also with our newly created network connection "MyWifiName".

5. This step is very impotent. Right click on you current internet connection icon (not on your MyWifiName icon). Click on the "Sharing" tab in the window you are getting. There tick the option "Allow other network users to connect through this computer's internet connection".
Then select your newly created MyWifiName connection as the "Home networking connection" in the drop down. There you won't have the name MyWifiName but the title name related to that connection. You can get that title name from Change adapter setting window. Click ok button.

6. Now you are done!

Turn on your Android or any device and connect to MyWifiName wifi hotspot using the password myPassword.

To turn off the network you created, enter the following command

netsh wlan stop hostednetwork


Monday, May 5, 2014

Simple Android Client-Server Application

This is an android application which sends a text message to a server. When you press the send button, the application sends the message in the text field to the server program. Here the program been written so that the client runs on the Android emulator and the server runs on the local host. IP address 10.0.2.2  can be used to connect to the local host with Android. Server program is continuously listening to the port 4444. When an incoming message arrived, server read it and show it on the standard output.
This tutorial is based on Android 4.4 (API Level 19 - KITKAT) version.



Following are the source codes of main components.

Android Text Client Application




Java Sever Program



Following are the both Android client and Java server complete projects. You can clone or download them as zips from Git-Hub.

Git-Hub HTTPS clone URL: https://github.com/lakjcomspace/AndroidTextClientServer.git
Git-Hub Repository URL: https://github.com/lakjcomspace/AndroidTextClientServer
Download as a Zip: https://github.com/lakjcomspace/AndroidTextClientServer/archive/master.zip
You can run the projects by importing them to the IDE. Or just create you own project and copy and paste above source files.

Tuesday, April 22, 2014

Start-Up, Shutdown or Restart the Tomcat Server Using an Ant build.xml


Following Ant build script can be used to start, stop or restart your Tomcat server. First you should set the property "tomcat.home" to your Tomcat home directory. Then when you just execute the "ant" command, it will restart your running server.
Here are all the commands you can use with this script.

Start Up:    "ant tomcat-start"
Shutdown:  "ant tomcat-stop"
Restart:      "ant" or "ant tomcat-restart"

Depending on the web application you are running, you may be getting an Out of Memory PermGen space error. If so, remove the comment marks and enable jvm argument <jvmarg value="-XX:MaxPermSize=256m"/> in the script (line 16).