Saturday, December 10, 2016

Eclipse: Create library project with the Android appcompat v7 support library

This video link nicely explains how to create a library project using the v7 support library for Android.

Tuesday, November 22, 2016

Nexus 5 disable autoplay music via bluetooth

Using Nexus 5 with kitkat 4.4.4, once you have paired a bluetooth device with your phone, you might have noticed when when the bluetooth device is detected and connected, music or videos starts playing automatically.

To disable this feature you need to go to

Settings -> bluetooth -> paired devices ->
Select the bluetooth device
under profiles -> uncheck "Media audio"

Tuesday, November 1, 2016

Nexus 5 power button reboot/restart

If you have an issue with your Nexus 5 phone's power button wherein the phone just restarts/reboots after pressing the power button then you need to boot in recovery mode and select 'wipe cache partition'. This worked for Kitkat 4.4.2 version of Android installed in the Nexus 5.

Detailed list of steps are present at this google link.

Registry key Error: Java version has value '1.8', but '1.7' is required


When working with multiple versions of Java SDK installed in your computer, you might come across this error where you have installed Java8 and then when you try to run/compile an application using Java6 or Java7 you get stuck.

Essentially you need to make sure that the  system 'path' variable points to the Java version that you need. When installing Java8 there are lot of folders that get added to the 'path' like 'C:\programdata\Oracle\Java\' or c:\program files\java\java8\nin, etc Once these folders are deleted from the 'path' variable then you will not get this error. Make sure that any windows command prompts are re-opened once changes have been done to the 'path' variable.

The below two posts nicely summarize the fix needed to make Java8 co-exist along with Java6/7.
http://stackoverflow.com/questions/26324486/properly-installing-java-8-along-with-java-7
http://stackoverflow.com/questions/29697543/registry-key-error-java-version-has-value-1-8-but-1-7-is-required

Sunday, June 5, 2016

How to add custom/local jars to a maven project as in-project repository

There are certain times when you will need to add a custom jar that is not present in a central or local repository as part of the maven build/compile goals. This jar along with others would need to be shipped out as part of the jar depdencies that are needed for the program to run. If you encounter such a suitation then follow the steps below to add the custom/local jar to your project.

1) Create a folder called 'lib' in your project root hierarchy.
For example if you have a project called c:\myTestProject then create a folder c:\myTestProject\lib

2) Copy the jar file to c:\myTestProject
For example lets say that we need to add a jar called abcd.jar to our project. So copy abcd.jar to c:\myTestProject\abcd.jar

3) Using maven 2.3 onwards, from windows command line, issue the command
mvn install:install-file -Dfile=c:\myTestProject\abcd.jar -DgroupId=com.xyz.myproject -DartifactId=abcd -Dversion=1.0.0 -Dpackaging=jar -DlocalRepositoryPath=c:\myTestProject\lib -DgeneratePom=true

After running that command, you will see the below folder created with the jar in it
c:\myTestProject\lib\com\xyz\myproject\abcd-1.0.0.jar


Now you can delete the c:\myTestProject\abcd.jar

4) Make the below changes to your projects pom.xml file

Note: file://${project.basedir}\lib has a \lib (backlash\lib) which is needed to work on windows computers
 

<project>
...
...

<repositories>
  <repository>
    <id>my-local-repo</id>
    <releases>
        <enabled>true</enabled>
    </releases>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
    <url>file://${project.basedir}\lib</url>
  </repository>
</repositories>

<dependencies>
    <dependency>
         <groupId>com.xyz.myproject</groupId>
        <artifactId>abcd</artifactId>
        <version>1.0.0</version>
    </dependency>
    ...
    ...
</dependencies>

...
...
<project>

After following the above steps, if you are still not able to build the project using maven and maven says that it cannot locate the abcd.jar file then check the maven settings ${maven_home}\.m2\settings.xml file
set the <mirrorOf> tag as mentioned below

<mirrors>
    <mirror>
        <mirrorOf>*<mirrorOf>
        ...
        ...
    </mirror>
</mirrors>

Running Java standlone app and spring xsd error message

When running java spring based standalone application, you might get an exception that spring is not able to validate the spring beans xsd file. This might due to the fact that your computer is behind a proxy and the java application does not have access to the proxy server. 

Assuming that you have a proxy server for internet configured with host as http.myproxy.net and port 9876 then run the java application with the below options will allow the application to launch

java -Dhttp.proxyHost=http.myproxy.net -Dhttp.proxyPort=9876 -Dhttp.proxyUser=someUserName -Dhttp.proxyPassword=somePassword -jar some-jar-to-run.jar