Search This Blog

Thursday, February 25, 2016

Java File content detector - Apache Tika

1. renamed sample.txt to sample.pdf

2. Add tika-core-1.11.jar in your lib

3. java class
    Output : text/plain File is of type - .txt


import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.tika.config.TikaConfig;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.mime.MediaType;
import org.apache.tika.mime.MimeType;
import org.apache.tika.mime.MimeTypeException;

public class TikaExample
{

    public static void main ( String [] args ) throws IOException, MimeTypeException
    {

      TikaConfig config = TikaConfig.getDefaultConfig ();

        // renamed sample.txt to sample.pdf
        File file = new File ( "D:/drvijay/Reliance/testing/sample.exe" );
        InputStream stream = new FileInputStream ( file );
        // whatever the source you get inputstream, please add buffer for mark/reset support,
        // else u may get exception
        InputStream bufferedIn = new BufferedInputStream ( stream );

        final Metadata metadata = new Metadata ();
        metadata.set ( Metadata.RESOURCE_NAME_KEY, file.getName () );
        MediaType mediaType = config.getMimeRepository ().detect ( bufferedIn, metadata );
        // MediaType mediaType = config.getMimeRepository ().detect ( bufferedIn, new Metadata() );
        MimeType mimeType = config.getMimeRepository ().forName ( mediaType.toString () );
        String extension = mimeType.getExtension ();

        System.out.println ( mimeType + " File is of type - " + extension );
    }
}

Monday, February 22, 2016

Chrome Hangs or Freezed

Follow these simple steps.

 1. Goto->start->run and type 

%appdata%

go back to appdata folder from roming folder. or simply open C:/Users/youruser/AppData

C:\Users\youruser\AppData\Local\Google\Chrome\User Data
 
1.1 delete default (folder) and  localstate (file)

 2. download google cleanup tool and run it

https://www.google.com/chrome/cleanup-tool/

2. open chrome as administrator
    Place mouse on chrome icon -> right click -> run as adminstrator


3.  disable shock/flash plugin 
type in chrome browser :

chrome://plugins

4. in chrome settings -> advance settings 

    4.1 change your download path,
     4.2 uncheck the [ use hardware acceralation when available ]
     4.3 uncheck the continue running background apps


ENJOY madi

Wednesday, February 10, 2016

Git or bitbucket checkout public key - Self signed certificate issue

git-Checkout
************


1. generate your self signed private key from "putty-gen.exe" or "open ssl" etc..
    > generate new key
    > save private key ex: D:/drvijay/self-private.ppk


2. type  the below command in cmd 1. to ignore ssl verify, 2. add your self certificate , 


3. check out 

    > git config --global http.sslverify false
    > git config --system http.sslCAPath D:/drvijay/self-private.ppk

    > git clone https://@url/repo.git
    > pwd: test123


-- Enjoy

Thursday, February 4, 2016

linux Ubuntu Postgresql Setup Installation


Type the below commands.


postgresql
**********

    sudo apt-get install postgresql postgresql-contrib
    apt-cache search postgres
    sudo apt-get install pgadmin3


create default user/role postgres
**********************************
    sudo -u postgres psql postgres
    \password postgres
    p0stgr3s
    p0stgr3s

linux Ubuntu SVN Setup Installation

svn
***
Type the below commands.
**********************

    sudo apt-get install subversion apache2 libapache2-svn

checkout
********
    svn co --username vijay svn://182.71.255.164/svn/repos/FastRaq/trunk/3.Implementation/Code/middleware
    enter pwd

Wednesday, February 3, 2016

linux Ubuntu Maven Setup Installation


Maven
*****

Type the below commands.

    sudo apt-get install maven
    sudo update-alternatives --config mvn

linux Ubuntu JDK Java Setup Installation

java 1.8
*******


Type the below commands.

    Installing Java 8
        $ sudo add-apt-repository ppa:webupd8team/java
        $ sudo apt-get update
        $ sudo apt-get install oracle-java8-installer
    Verify java
        $ java -version
    Configuring Java Environment
        $ sudo apt-get install oracle-java8-set-default


linux Ubuntu Git Setup Installation

Git
***
Type the below commands.

    sudo apt-get install git-core
    git clone https://github.com/ebhaiah/middleware-soa.git

Linux - Ubuntu - Mongodb Installation Setup



mongodb
*******


1.    Install MongoDB
    Import the public key used by the package management system.

    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

2Create a list file for MongoDB.

    echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

3 Reload local package database.

    sudo apt-get update

4 Install the MongoDB packages.

    sudo apt-get install -y mongodb-org

4.1 Install a specific release of MongoDB.

    sudo apt-get install -y mongodb-org=3.0.7 mongodb-org-server=3.0.7 mongodb-org-shell=3.0.7 mongodb-org-mongos=3.0.7 mongodb-org-tools=3.0.7

5. Start MongoDB.

    sudo service mongod start

5.1 Verify that MongoDB has started successfully
    Verify that the mongod process has started successfully by checking the contents of the log file at /var/log/mongodb/mongod.log for a line reading

6 Stop MongoDB.

    sudo service mongod stop

7 Restart MongoDB.
   
    sudo service mongod restart

8. mongodb - uninstall

    sudo service mongod stop
    sudo apt-get purge mongodb-org*
    sudo rm -r /var/log/mongodb
    sudo rm -r /var/lib/mongodb

Wednesday, January 6, 2016

Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinit ionParsingException: Configuration problem: Unable to locate SpringNamespaceHandler for XML schema namespace [http://www.springframework.org/schema/tx] Offending resource: class path resource [spring.xml]

When you get this error: please use maven-shade-plugin instead of maven-assembly-plugin

<!--
            #if you use this maven assembly plugin with spring-tx, you may get unable to locate exception while running as single jar. so use shade plugin
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <phase>package</phase> bind to the packaging phase
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>yourpackage.YourMainClass</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
            -->
            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>1.4</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>yourpackage.YourMainClass</mainClass>
                            </transformer>
                            <transformer
                                implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>META-INF/spring.handlers</resource>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
       

Hit Counter


View My Stats