Thursday, 22 December 2016

How to start MongoDB In Windows?

Open CMD as Administer  and Type flowing command....


>Mongod.exe --install --logpath c:\data\logs.log --logappend --bind_ip 127.0.0.1 --dbpath c:\data\db --directoryperdb

after execution type..

>net Start Mongodb

>Mongo.exe


Friday, 2 December 2016

Simple video streaming Example In HTML5

Here we not Use any RTMP protocol in Server side. 
This video Is simply present in server  Side.And Browser is download file as stream and feed to Our video element.  

       <video src="http://youlearners.com/streaming/Avengers2.mp4"
               controls preload="auto" width="640" height="264"
               data-setup='{"controls":true}'>
            <source type='video/mp4' />
     </video>

 <!---here i Use data-setup='{"controls":true}' and preload="auto" for load and play simultaneously---->

OPTPUT

Friday, 25 November 2016

How to control arduino connected Servo motor from an android app Over Bluetooth connection ?

You can get your connection and device assembling from another stuffs.Here I place My code which i developed. which may useful for You. 

For Any Query comment below ..

//Arduino code..


       
#include <Servo.h>
int pos=0;
int servoPin=9;
int servoDelay=25;
Servo myPointer;

char data = 0;                //Variable for storing received data
void setup() 
{
  Serial.begin(9600);         //Sets the data rate in bits per second (baud) for serial data transmission
  //pinMode(13, OUTPUT);        //Sets digital pin 13 as output pin
  myPointer.attach(servoPin);
}
void loop()
{
  if(Serial.available() > 0)  // Send data only when you receive data:
  {
    while(Serial.available()==0){}
    pos=Serial.parseInt();
    myPointer.write(pos);
  }
}

 

//code FOR android application

AndroidManifest.xml file
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.example.kiit1.audrinoblutooth">
    <uses-sdk        android:minSdkVersion="8"        android:targetSdkVersion="17" />
    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

    <application        android:allowBackup="true"        android:icon="@mipmap/ic_launcher"        android:label="@string/app_name"        android:supportsRtl="true"        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

activity_main.xml File
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/activity_main"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:paddingBottom="@dimen/activity_vertical_margin"    android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    tools:context="com.example.kiit1.audrinoblutooth.MainActivity">

    <EditText android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:inputType="number"
              android:ems="10"  
              android:layout_alignParentTop="true"  
              android:layout_centerHorizontal="true" 
              android:layout_marginTop="184dp"  
              android:id="@+id/editText" />

    <Button   android:text="Move"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"  
              android:layout_alignParentBottom="true"
              android:layout_alignStart="@+id/button"
              android:layout_marginBottom="82dp"
              android:id="@+id/button2" />

    <Button   android:text="Button" 
              android:layout_width="wrap_content" 
              android:layout_height="wrap_content"
              android:layout_marginTop="45dp" 
              android:id="@+id/button"
              android:layout_alignParentTop="true" 
              android:layout_centerHorizontal="true" />
</RelativeLayout>
for mainActivity 
package com.example.kiit1.audrinoblutooth;

import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.os.ParcelUuid;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Set;

public class MainActivity extends AppCompatActivity {
    private OutputStream outputStream;
    private InputStream inStream;

    @Override    protected void onCreate(Bundle savedInstanceState) {
        int position=0;
        try {
            BluetoothAdapter blueAdapter = BluetoothAdapter.getDefaultAdapter();
            if (blueAdapter != null) {

                if (blueAdapter.isEnabled()) {
                    Set<BluetoothDevice> bondedDevices = blueAdapter.getBondedDevices();

                    if (bondedDevices.size() > 0) {
                        Object[] devices = (Object[]) bondedDevices.toArray();
                        Toast.makeText(getBaseContext(), devices.length+"", Toast.LENGTH_LONG).show();
                        BluetoothDevice device = (BluetoothDevice) devices[position];
                        ParcelUuid[] uuids = device.getUuids();
                        BluetoothSocket socket = device.createRfcommSocketToServiceRecord(uuids[0].getUuid());
                        socket.connect();
                        outputStream = socket.getOutputStream();
                        inStream = socket.getInputStream();
                    }

                    Log.e("error", "No appropriate paired devices.");
                } else {
                    Log.e("error", "Bluetooth is disabled.");
                }
            }
        }catch(Exception e){
            e.printStackTrace();
            Toast.makeText(getBaseContext(), "SETUP Failure", Toast.LENGTH_LONG).show();
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            //Creating dialog box            AlertDialog alert = builder.create();
            //Setting the title manually            alert.setTitle("Error");
            String sErr=e.toString();
            alert.setMessage(sErr);
            alert.show();

        }


        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button button2=(Button)findViewById(R.id.button2);
        final EditText editText=(EditText)findViewById(R.id.editText);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View v) {
             String str= editText.getText().toString();
                try {
                    write(str);
                }catch(Exception e){
                    Toast.makeText(getBaseContext(), "Connection Failure", Toast.LENGTH_LONG).show();
                }
            }
        });
    }

    public void write(String s) throws IOException {
        outputStream.write(s.getBytes());
    }
}


OUT PUT




It rotate degree you Send form your app..

Wednesday, 23 November 2016

How to convert pptx file to Image and pdf in Java ?

       
//Here I Use APACHE POI and ITEXT JAVA API
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;

import org.apache.poi.xslf.usermodel.*;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.PdfWriter;

public class MakePPTtoPDF {
 public static void main(String args[]) throws IOException{
       
       //creating an empty presentation
       File file=new File("D:/Exam2016Kiit/HTTP Over WebSocket Proxy System.pptx");
       XMLSlideShow ppt = new XMLSlideShow(new FileInputStream(file));
       
       
       //getting the dimensions and size of the slide
       
       Dimension pgsize = ppt.getPageSize();
       List<XSLFSlide> slide = ppt.getSlides();
       BufferedImage img=null;
       Document doc=new Document();
         try {
    PdfWriter.getInstance(doc, new  FileOutputStream("C:/Users/kiit1/Desktop/aca/PPTImages.pdf"));
   
         doc.open();

       for (int i = 0; i < slide.size(); i++) {
          img = new BufferedImage(pgsize.width, pgsize.height,BufferedImage.TYPE_INT_RGB);
          Graphics2D graphics = img.createGraphics();

          //clear the drawing area
          graphics.setPaint(Color.white);
          graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));

          //render
          slide.get(i).draw(graphics);
          FileOutputStream out = new FileOutputStream("C:/Users/kiit1/Desktop/aca/"+i+".png");
        javax.imageio.ImageIO.write(img, "png", out);
        ppt.write(out);
        com.itextpdf.text.Image image =com.itextpdf.text.Image.getInstance("C:/Users/kiit1/Desktop/aca/"+i+".png");
             doc.setPageSize(new com.itextpdf.text.Rectangle(image.getScaledWidth(), image.getScaledHeight()));
             doc.newPage();
             image.setAbsolutePosition(0, 0);
             doc.add(image);

        System.out.println("Image successfully created");
        out.close();
       }
       doc.close();
         } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
       
        
    }

 
}

 


OUTPUT

AND MY OUT PUT FILE IS HERE

Friday, 18 November 2016

Detect your face using opencv in java

     // first SetUp Your OpenCV lib with Eclips IDE
  
package opencvtest;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.MatOfRect;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.highgui.Highgui;
import org.opencv.objdetect.CascadeClassifier;

//
// Detects faces in an image, draws boxes around them, and writes the results
// to "faceDetection.png".
//
class DetectFaceDemo {
  public void run() {
    System.out.println("\nRunning DetectFaceDemo");

    // Create a face detector from the cascade file in the resources
    // directory.
   // CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("lbpcascade_frontalface.xml").getPath());
   CascadeClassifier faceDetector = new CascadeClassifier("D:/javaTech/OpenCV/opencv/sources/data/lbpcascades/lbpcascade_frontalface.xml");
//    Mat image = Highgui.imread("C:/Users/kiit1/Desktop/IMG_2096.JPG");
    Mat image = Highgui.imread("C:/Users/kiit1/Desktop/b.JPG");

    // Detect faces in the image.
    // MatOfRect is a special container class for Rect.
    MatOfRect faceDetections = new MatOfRect();
    faceDetector.detectMultiScale(image, faceDetections);

    System.out.println(String.format("Detected %s faces", faceDetections.toArray().length));

    // Draw a bounding box around each face.
    for (Rect rect : faceDetections.toArray()) {
        Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0));
    }

    // Save the visualized detection.
    String filename = "C:/Users/kiit1/Desktop/lenafaceDetection.png";
    System.out.println(String.format("Writing %s", filename));
    Highgui.imwrite(filename, image);
  }
}

//Main.java (Execute this)
package opencvtest;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;

import java.io.File;
import javax.imageio.ImageIO;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.imgproc.Imgproc;

public class Main {
   public static void main( String[] args ) { 
   
      try {
         System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
         File input = new File("C:/Users/kiit1/Desktop/lena.png");
         BufferedImage image = ImageIO.read(input); 

         byte[] data = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
         Mat mat = new Mat(image.getHeight(), image.getWidth(), CvType.CV_8UC3);
         mat.put(0, 0, data);

         Mat mat1 = new Mat(image.getHeight(),image.getWidth(),CvType.CV_8UC1);
         Imgproc.cvtColor(mat, mat1, Imgproc.COLOR_RGB2GRAY);

         byte[] data1 = new byte[mat1.rows() * mat1.cols() * (int)(mat1.elemSize())];
         mat1.get(0, 0, data1);
         BufferedImage image1 = new BufferedImage(mat1.cols(),mat1.rows(), BufferedImage.TYPE_BYTE_GRAY);
         image1.getRaster().setDataElements(0, 0, mat1.cols(), mat1.rows(), data1);

         File ouptut = new File("C:/Users/kiit1/Desktop/grayscale.jpg");
         ImageIO.write(image1, "jpg", ouptut);
         
      } catch (Exception e) {
         System.out.println("Error: " + e.getMessage());
      }
   }
}
 

OutPut

Wednesday, 2 November 2016

Create a Hotsport in java(Useing OS primitives) !!!!

       
/*
 * Jyotiprakash
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Hotsport {

 public static void main(String[] args) {        
     try {

         System.out.println("-- Setting up WLAN --");
         String netshCommand = "netsh wlan set hostednetwork mode=allow ssid=\"YourSSID\" key=\"YourPassword\" & exit";
         String[] elevateCommand = new String[]{"./Release/elevate.exe", "-wait", "-k", "prog", netshCommand};
         ProcessBuilder pb1 = new ProcessBuilder(elevateCommand);
         Process p1 = pb1.start();
         p1.waitFor();

         System.out.println("-- Starting WLAN --");
         netshCommand = "netsh wlan start hostednetwork & exit";
         elevateCommand = new String[]{"./Release/elevate.exe", "-wait", "-k", "prog", netshCommand};
         ProcessBuilder pb2 = new ProcessBuilder(elevateCommand);
         Process p2 = pb2.start();
         p2.waitFor();

         System.out.println("-- Setting up IPv4 interface --");
         netshCommand = "netsh interface ipv4 set address \"Conexión de red inalámbrica\" static 192.168.0.102 255.255.255.0 192.168.0.254 & exit";
         elevateCommand = new String[]{"./Release/elevate.exe", "-wait", "-k", "prog", netshCommand};
         ProcessBuilder pb3 = new ProcessBuilder(elevateCommand);
         Process p3 = pb3.start();
         p3.waitFor();

         System.out.println("-- Getting IPv4 interface dump --");
         netshCommand = "netsh interface ipv4 dump";
         ProcessBuilder pb4 = new ProcessBuilder("cmd.exe", "/c", netshCommand);
         Process p4 = pb4.start();

         System.out.println("-- Printing IPv4 interface dump --");
         BufferedReader bfr = new BufferedReader(new InputStreamReader(p4.getInputStream(),"ISO-8859-1"));
         String output;
         while((output = bfr.readLine()) != null){
             System.out.println(output);
         }

     } catch (Exception ex) {
         ex.printStackTrace();
     }

 }
}

 

IMAGE Stenography in java

 public class Image_Filter extends javax.swing.filechooser.FileFilter
{
 /*
  *Determines if the extension is of the defined types
  *@param ext Extension of a file
  *@return Returns true if the extension is 'jpg' or 'png'
  */
 protected boolean isImageFile(String ext)
 {
  return (ext.equals("jpg")||ext.equals("png"));
 }
 
 /*
  *Determines if the file is a directory or accepted extension
  *@param f The File to run the directory/proper extension check on
  *@return Returns true if the File is a directory or accepted extension
  */
 public boolean accept(File f)
 {
     if (f.isDirectory())
     {
   return true;
     }

     String extension = getExtension(f);
  if (extension.equals("jpg")||extension.equals("png"))
  {
   return true;
  }
  return false;
 }
 
 /*
  *Supplies File type description
  *@return Returns the String description
  */
 public String getDescription()
 {
  return "Supported Image Files";
 }
 
 /*
  *Determines the Extension
  *@param f File to return the extension of
  *@return Returns the String representing the extension
  */
 protected static String getExtension(File f)
 {
  String s = f.getName();
  int i = s.lastIndexOf('.');
  if (i > 0 &&  i < s.length() - 1) 
    return s.substring(i+1).toLowerCase();
  return "";
 } 
}
// Steganography_Controller.java     


import java.io.File;

import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.awt.event.ActionListener;

import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import javax.swing.JMenuItem;
import javax.swing.JTextArea;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;
import javax.swing.JFileChooser;

/*
 *Steganography_Controller Class
 */
public class Steganography_Controller
{
 //Program Variables
 private Steganography_View view;
 private Steganography  model;
 
 //Panel Displays
 private JPanel  decode_panel;
 private JPanel  encode_panel;
 //Panel Variables
 private JTextArea  input;
 private JButton  encodeButton,decodeButton;
 private JLabel  image_input;
 //Menu Variables
 private JMenuItem  encode;
 private JMenuItem  decode;
 private JMenuItem  exit;
 
 //action event classes
 private Encode   enc;
 private Decode   dec;
 private EncodeButton encButton;
 private DecodeButton decButton;
 
 //decode variable
 private String   stat_path = "";
 private String   stat_name = "";
 
 /*
  *Constructor to initialize view, model and environment variables
  *@param aView  A GUI class, to be saved as view
  *@param aModel A model class, to be saved as model
  */
 public Steganography_Controller(Steganography_View aView, Steganography aModel)
 {
  //program variables
  view  = aView;
  model = aModel;
  
  //assign View Variables
  //2 views
  encode_panel = view.getTextPanel();
  decode_panel = view.getImagePanel();
  //2 data options
  input   = view.getText();
  image_input  = view.getImageInput();
  //2 buttons
  encodeButton = view.getEButton();
  decodeButton = view.getDButton();
  //menu
  encode   = view.getEncode();
  decode   = view.getDecode();
  exit   = view.getExit();
  
  //assign action events
  enc = new Encode();
  encode.addActionListener(enc);
  dec = new Decode();
  decode.addActionListener(dec);
  exit.addActionListener(new Exit());
  encButton = new EncodeButton();
  encodeButton.addActionListener(encButton);
  decButton = new DecodeButton();
  decodeButton.addActionListener(decButton);
  
  //encode view as default
  encode_view();
 }
 
 /*
  *Updates the single panel to display the Encode View.
  */
 private void encode_view()
 {
  update();
  view.setContentPane(encode_panel);
  view.setVisible(true);
 }
 
 /*
  *Updates the single panel to display the Decode View.
  */
 private void decode_view()
 {
  update();
  view.setContentPane(decode_panel);
  view.setVisible(true);
 }
 
 /*
  *Encode Class - handles the Encode menu item
  */
 private class Encode implements ActionListener
 {
  /*
   *handles the click event
   *@param e The ActionEvent Object
   */
  public void actionPerformed(ActionEvent e)
  {
   encode_view(); //show the encode view
  }
 }
 
 /*
  *Decode Class - handles the Decode menu item
  */
 private class Decode implements ActionListener
 {
  /*
   *handles the click event
   *@param e The ActionEvent Object
   */
  public void actionPerformed(ActionEvent e)
  {
   decode_view(); //show the decode view
   
   //start path of displayed File Chooser
   JFileChooser chooser = new JFileChooser("./");
   chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
   chooser.setFileFilter(new Image_Filter());
   int returnVal = chooser.showOpenDialog(view);
   if (returnVal == JFileChooser.APPROVE_OPTION){
    File directory = chooser.getSelectedFile();
    try{
     String image = directory.getPath();
     stat_name = directory.getName();
     stat_path = directory.getPath();
     stat_path = stat_path.substring(0,stat_path.length()-stat_name.length()-1);
     stat_name = stat_name.substring(0, stat_name.length()-4);
     image_input.setIcon(new ImageIcon(ImageIO.read(new File(image))));
    }
    catch(Exception except) {
    //msg if opening fails
    JOptionPane.showMessageDialog(view, "The File cannot be opened!", 
     "Error!", JOptionPane.INFORMATION_MESSAGE);
    }
   }
  }
 }
 
 /*
  *Exit Class - handles the Exit menu item
  */
 private class Exit implements ActionListener
 {
  /*
   *handles the click event
   *@param e The ActionEvent Object
   */
  public void actionPerformed(ActionEvent e)
  {
   System.exit(0); //exit the program
  }
 }
 
 /*
  *Encode Button Class - handles the Encode Button item
  */
 private class EncodeButton implements ActionListener
 {
  /*
   *handles the click event
   *@param e The ActionEvent Object
   */
  public void actionPerformed(ActionEvent e)
  {
   //start path of displayed File Chooser
   JFileChooser chooser = new JFileChooser("./");
   chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
   chooser.setFileFilter(new Image_Filter());
   int returnVal = chooser.showOpenDialog(view);
   if (returnVal == JFileChooser.APPROVE_OPTION){
    File directory = chooser.getSelectedFile();
    try{
     String text = input.getText();
     String ext  = Image_Filter.getExtension(directory);
     String name = directory.getName();
     String path = directory.getPath();
     path = path.substring(0,path.length()-name.length()-1);
     name = name.substring(0, name.length()-4);
     
     String stegan = JOptionPane.showInputDialog(view,
         "Enter output file name:", "File name",
         JOptionPane.PLAIN_MESSAGE);
     
     if(model.encode(path,name,ext,stegan,text))
     {
      JOptionPane.showMessageDialog(view, "The Image was encoded Successfully!", 
       "Success!", JOptionPane.INFORMATION_MESSAGE);
     }
     else
     {
      JOptionPane.showMessageDialog(view, "The Image could not be encoded!", 
       "Error!", JOptionPane.INFORMATION_MESSAGE);
     }
     //display the new image
     decode_view();
     image_input.setIcon(new ImageIcon(ImageIO.read(new File(path + "/" + stegan + ".png"))));
    }
    catch(Exception except) {
    //msg if opening fails
    JOptionPane.showMessageDialog(view, "The File cannot be opened!", 
     "Error!", JOptionPane.INFORMATION_MESSAGE);
    }
   }
  }
  
 }
 
 /*
  *Decode Button Class - handles the Decode Button item
  */
 private class DecodeButton implements ActionListener
 {
  /*
   *handles the click event
   *@param e The ActionEvent Object
   */
  public void actionPerformed(ActionEvent e)
  {
   String message = model.decode(stat_path, stat_name);
   System.out.println(stat_path + ", " + stat_name);
   if(message != "")
   {
    encode_view();
    JOptionPane.showMessageDialog(view, "The Image was decoded Successfully!", 
       "Success!", JOptionPane.INFORMATION_MESSAGE);
    input.setText(message);
   }
   else
   {
    JOptionPane.showMessageDialog(view, "The Image could not be decoded!", 
       "Error!", JOptionPane.INFORMATION_MESSAGE);
   }
  }
 }
 
 /*
  *Updates the variables to an initial state
  */
 public void update()
 {
  input.setText("");   //clear textarea
  image_input.setIcon(null); //clear image
  stat_path = "";    //clear path
  stat_name = "";    //clear name
 }
 
 /*
  *Main Method for testing
  */
 public static void main(String args[])
 {
  new Steganography_Controller(
         new Steganography_View("Steganography"),
         new Steganography()
         );
 }
}
//Steganography_View.java


import java.awt.Color;
import java.awt.Insets;
import java.awt.Container;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;

import javax.swing.JMenu;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTextArea;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.BorderFactory;

/*
 *Class Steganography_View
 */
public class Steganography_View extends JFrame
{
 //sie variables for window
 private static int WIDTH  = 500;
 private static int HEIGHT = 400;
 
 //elements for JPanel
 private JTextArea  input;
 private JScrollBar  scroll,scroll2;
 private JButton  encodeButton,decodeButton;
 private JLabel  image_input;
 
 //elements for Menu
 private JMenu   file;
 private JMenuItem  encode;
 private JMenuItem  decode;
 private JMenuItem  exit;
 
 /*
  *Constructor for Steganography_View class
  *@param name Used to set the title on the JFrame
  */
 public Steganography_View(String name)
 {
  //set the title of the JFrame
  super(name);
  
  //Menubar
  JMenuBar menu = new JMenuBar();
  
  JMenu file = new JMenu("File"); file.setMnemonic('F');
  encode = new JMenuItem("Encode"); encode.setMnemonic('E'); file.add(encode);
  decode = new JMenuItem("Decode"); decode.setMnemonic('D'); file.add(decode);
  file.addSeparator();
  exit = new JMenuItem("Exit"); exit.setMnemonic('x'); file.add(exit);
  
  menu.add(file);
  setJMenuBar(menu);
  
  // display rules
  setResizable(true);      //allow window to be resized: true?false
  setBackground(Color.lightGray);   //background color of window: Color(int,int,int) or Color.name
  setLocation(100,100);     //location on the screen to display window
        setDefaultCloseOperation(EXIT_ON_CLOSE);//what to do on close operation: exit, do_nothing, etc
        setSize(WIDTH,HEIGHT);     //set the size of the window
        setVisible(true);      //show the window: true?false
 }
 
 /*
  *@return The menu item 'Encode'
  */
 public JMenuItem getEncode()  { return encode;   }
 /*
  *@return The menu item 'Decode'
  */
 public JMenuItem getDecode()  { return decode;   }
 /*
  *@return The menu item 'Exit'
  */
 public JMenuItem getExit()  { return exit;    }
 /*
  *@return The TextArea containing the text to encode
  */
 public JTextArea getText()  { return input;    }
 /*
  *@return The JLabel containing the image to decode text from
  */
 public JLabel  getImageInput() { return image_input;  }
 /*
  *@return The JPanel displaying the Encode View
  */
 public JPanel  getTextPanel() { return new Text_Panel(); }
 /*
  *@return The JPanel displaying the Decode View
  */
 public JPanel  getImagePanel() { return new Image_Panel(); }
 /*
  *@return The Encode button
  */
 public JButton  getEButton() { return encodeButton;  }
 /*
  *@return The Decode button
  */
 public JButton  getDButton() { return decodeButton;  }
 
 /*
  *Class Text_Panel
  */
 private class Text_Panel extends JPanel
 {
  /*
   *Constructor to enter text to be encoded
   */
  public Text_Panel()
  {
   //setup GridBagLayout
   GridBagLayout layout = new GridBagLayout(); 
   GridBagConstraints layoutConstraints = new GridBagConstraints(); 
   setLayout(layout);
   
   input = new JTextArea();
   layoutConstraints.gridx  = 0; layoutConstraints.gridy = 0; 
   layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; 
   layoutConstraints.fill   = GridBagConstraints.BOTH; 
   layoutConstraints.insets  = new Insets(0,0,0,0); 
   layoutConstraints.anchor  = GridBagConstraints.CENTER; 
   layoutConstraints.weightx  = 1.0; layoutConstraints.weighty = 50.0;
   JScrollPane scroll = new JScrollPane(input,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
   JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 
   layout.setConstraints(scroll,layoutConstraints);
   scroll.setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
      add(scroll);
      
      encodeButton = new JButton("Encode Now");
      layoutConstraints.gridx  = 0; layoutConstraints.gridy = 1; 
   layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; 
   layoutConstraints.fill   = GridBagConstraints.BOTH; 
   layoutConstraints.insets  = new Insets(0,-5,-5,-5); 
   layoutConstraints.anchor  = GridBagConstraints.CENTER; 
   layoutConstraints.weightx  = 1.0; layoutConstraints.weighty = 1.0;
   layout.setConstraints(encodeButton,layoutConstraints);
      add(encodeButton);
      
      //set basic display
   setBackground(Color.lightGray);
   setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
  }
 }
 
 /*
  *Class Image_Panel
  */
 private class Image_Panel extends JPanel
 {
  /*
   *Constructor for displaying an image to be decoded
   */
  public Image_Panel()
  {
   //setup GridBagLayout
   GridBagLayout layout = new GridBagLayout(); 
   GridBagConstraints layoutConstraints = new GridBagConstraints(); 
   setLayout(layout);
   
   image_input = new JLabel();
   layoutConstraints.gridx  = 0; layoutConstraints.gridy = 0; 
   layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; 
   layoutConstraints.fill   = GridBagConstraints.BOTH; 
   layoutConstraints.insets  = new Insets(0,0,0,0); 
   layoutConstraints.anchor  = GridBagConstraints.CENTER; 
   layoutConstraints.weightx  = 1.0; layoutConstraints.weighty = 50.0;
   JScrollPane scroll2 = new JScrollPane(image_input,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
   JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 
   layout.setConstraints(scroll2,layoutConstraints);
   scroll2.setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
   image_input.setHorizontalAlignment(JLabel.CENTER);
      add(scroll2);
      
      decodeButton = new JButton("Decode Now");
      layoutConstraints.gridx  = 0; layoutConstraints.gridy = 1; 
   layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; 
   layoutConstraints.fill   = GridBagConstraints.BOTH; 
   layoutConstraints.insets  = new Insets(0,-5,-5,-5); 
   layoutConstraints.anchor  = GridBagConstraints.CENTER; 
   layoutConstraints.weightx  = 1.0; layoutConstraints.weighty = 1.0;
   layout.setConstraints(decodeButton,layoutConstraints);
      add(decodeButton);
      
      //set basic display
   setBackground(Color.lightGray);
   setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
     }
  }
 
 /*
  *Main Method for testing
  */
 public static void main(String args[])
 {
  new Steganography_View("Steganography");
 }
}
 

Thursday, 25 August 2016

How to make mouse and keyboard press using java program !!!!

       
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
 
public class KeyStroke {
 
 public static void main(String[] args) throws AWTException {
 
  Robot robot = new Robot();
 
     robot.delay(3000);
 
     robot.keyPress(KeyEvent.VK_Q);
     // MIDDLE WHEEL CLICK
        robot.mousePress(InputEvent.BUTTON3_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);

        // SCROLL THE MOUSE WHEEL
        robot.mouseWheel(-100);
        
     // RIGHT CLICK
        robot.mousePress(InputEvent.BUTTON3_MASK);
        robot.mouseRelease(InputEvent.BUTTON3_MASK);
        
     // LEFT CLICK
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

     // SET THE MOUSE X Y POSITIONq
        robot.mouseMove(300, 550);
 }
}
 

Tuesday, 7 June 2016

How take Screenshot in java Program

       
package com.trail;


import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
 
import javax.imageio.ImageIO;
 

public class FullScreenCaptureExample {
 
    public static void main(String[] args) {
        try {
            Robot robot = new Robot();
            String format = "jpg";
            String fileName = "PartialScreenshot." + format;
             
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            Rectangle captureRect = new Rectangle(0, 0, screenSize.width / 2, screenSize.height / 2);
            BufferedImage screenFullImage = robot.createScreenCapture(captureRect);
            ImageIO.write(screenFullImage, format, new File(fileName));
             
            System.out.println("A partial screenshot saved!");
        } catch (AWTException | IOException ex) {
            System.err.println(ex);
        }
    }
}
 

It will show as....



Saturday, 7 May 2016

How to invoke seter &geter Method of a java bean Using Java Reflection..!!

//Code......

import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;

public class InvokeSetterGetter {

   public static void main(String[] args) {
    /* Create object of Actor. */
    Actor objActor = new Actor();

    InvokeSetterGetter objInvokeSetterGetter = 
                  new InvokeSetterGetter();
    /* Call invokeSetter method */
 objInvokeSetterGetter.invokeSetter(objActor, "Name", "Benedict Cumberbatch");
    /* Call invokeGetter method */
 objInvokeSetterGetter.invokeGetter(objActor, "Name");
   }
 
 private void invokeSetter(Object obj,
                  String variableName,
                 Object variableValue){
   /* variableValue is Object because value can 
      be an Object, Integer, String, etc... */
      try {
   /**
   * Get object of PropertyDescriptor
    using variable name and class
    * Note: To use PropertyDescriptor on any 
   field/variable, the field must have both `Setter` and `Getter` method.
         */
 PropertyDescriptor objPropertyDescriptor =
 new PropertyDescriptor(variableName,
                      obj.getClass());
    /* Set field/variable value 
           using getWriteMethod() */
 objPropertyDescriptor.getWriteMethod().invoke(obj,
                                     variableValue);
      } 
catch (IllegalAccessException | IllegalArgumentException
 | InvocationTargetException | IntrospectionException e) {
        /* Java 8: Multiple exception
 in one catch. Use Different catch block for lower version. */
        e.printStackTrace();
      }
   }

   private void invokeGetter(Object obj, String variableName){
      try {
        /**
         * Get object of PropertyDescriptor
         using variable name and class
         * Note: To use PropertyDescriptor
        on any field/variable,
        the field must have both `Setter` and `Getter` method.
         */
  PropertyDescriptor objPropertyDescriptor =
new PropertyDescriptor(variableName, obj.getClass());
        /**
 * Get field/variable value using getReadMethod()
 * variableValue is Object
  because value can be an Object, Integer, String, etc...
  */
Object variableValue=objPropertyDescriptor.getReadMethod().invoke(obj);
/* Print value of variable */
         System.out.println(variableValue);
 } catch (IllegalAccessException | IllegalArgumentException
 | InvocationTargetException | IntrospectionException e) {
  /* Java 8: Multiple exception in
 one catch. Use Different catch block for lower version. */
  e.printStackTrace();
      }
   }
}


Friday, 22 April 2016

Convert Java (JDBC) ResultSet to JSON Using RStoJSON API in Java

This API  is develop by me.It convert ResultSet to JSON String..By invoking a static Method present in Converter CLASS.(download RStoJSON.jar from here)

ResultSet rs=ps.executeQuery();
 

String jsonString=com.learners.converter.Converter.rsTojson(rs);

Use Code As
Set jar file in lib Folder
It will give Out put As
(its a web service output on postman)

Thursday, 21 April 2016

How to make ResultSet Object to JSON String in Java

package com.learners.converter;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.ArrayList;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.mysql.jdbc.jdbc2.optional.SuspendableXAConnection;

/**
 * @author jyotioeuvretc.com
 *
 */
public class Converter {

 /**
  * @param args
  */
 public static void main(String[] args) {
     try {
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://192.168.0.29/scylla","root","root");
PreparedStatement ps=con.prepareStatement("SELECT * FROM view_promocode_doctor ");
ResultSet rs=ps.executeQuery();
ResultSetMetaData rsm=rs.getMetaData();
System.out.println("col="+rsm.getColumnCount()+"table="+rsm.getTableName(1));
ArrayList<StringBuilder> collist=new ArrayList<StringBuilder>();
  
while(rs.next()){
StringBuilder sb=new StringBuilder();
sb.append("{");
for(int i=1;i<rsm.getColumnCount()+1;i++){ 
   
    //System.out.println(rsm.getColumnName(i)+":"+rs.getString(i)+",");
if(i==rsm.getColumnCount())
{
 sb.append("\""+rsm.getColumnName(i)+"\":\""+rs.getString(i)+"\"");
}
else
{
 sb.append("\""+rsm.getColumnName(i)+"\":\""+rs.getString(i)+"\",");
}
}
    
sb.append("}");
collist.add(sb);
}
//OutPut
 System.out.println(collist.toString());
  
 } catch (Exception e) {
  e.printStackTrace();
 }
     
     
  
 }

}
          


It give Output As....

 

Tuesday, 19 April 2016

How to Use media Query in CSS to change the style according to screen width ?

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<style>
body {
    background-color:lightgreen;
}


@media only screen and (max-width:600px){
   body{
        background-color:black;

     }
}
@media only screen and (max-width: 500px) {
    body {
        background-color:lightblue;
    }
}
</style>
</head>
<body>
<p>Resize the browser window. When the width of this document is less than 500 pixels,
 the background-color is "lightblue", otherwise it is "lightgreen".</p>
</body>
</html>

It will work as....







Resize the browser window. When the width of this document is
less than 500 pixels, the background-color is "lightblue",
otherwise it is "lightgreen".

how to filter input element in html 5 ?

Only audio.....<input accept="audio/*;capture=microphone" type="file" />
It will work as__


Friday, 15 April 2016

how to share your website in Facebook by javascript ?

 
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<!-- facebook login -->
<script>
//Load the Facebook JS SDK
     (function (d) {
        var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
        if (d.getElementById(id)) {
            return;
        }
        js = d.createElement('script');
        js.id = id;
        js.async = true;
        js.src = "https://connect.facebook.net/en_US/all.js";
        ref.parentNode.insertBefore(js, ref);
    }(document)); 
    
    
    /* (function(d, s, id){
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));
 */
// Init the SDK upon load
    window.fbAsyncInit = function () {
        FB.init({
            appId: '1459247121050170',//0
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true, // parse XFBML
            version: 'v2.5' // old  v2.4
        });


// Specify the extended permissions needed to view user data
// The user will be asked to grant these permissions to the app (so only pick those that are needed)
//public_profile,email
        var permissions = [
            'public_profile',
            'email',
        ].join(',');

        var fields = [
            'id',
            'name',
            'first_name',
            'middle_name',
            'last_name',
            'gender',
            'locale',
            'languages',
            'link',
            'third_party_id',
            'installed',
            'timezone',
            'updated_time',
            'verified',
            'age_range',
            'bio',
            'birthday',
            'cover',
            'currency',
            'devices',
            'education',
            'email',
            'hometown',
            'interested_in',
            'location',
            'political',
            'payment_pricepoints',
            'favorite_athletes',
            'favorite_teams',
            'picture',
            'quotes',
            'relationship_status',
            'religion',
            'significant_other',
            'video_upload_limits',
            'website',
            'work'
        ].join(',');

        function showDetails() {
            FB.api('/me', {fields: fields}, function (details) {

                alert(JSON.stringify(details));  // display all the details

                var res = jQuery.parseJSON(JSON.stringify(details));
                /* alert(res.payment_pricepoints.mobile.length);
     for(var i=0;i<res.payment_pricepoints.mobile.length;i++){   
      alert(res.payment_pricepoints.mobile[i].local_currency);
     } */
                var email = res.email;
                var firstName = res.first_name;
                var lastName = res.last_name;
                var gender = res.gender;
                var profielPictureURL = res.picture.data.url;
                //alert(profielPictureURL);

                profielPictureURL = profielPictureURL.replace(/&/g, "@");
                //alert(profielPictureURL);

                var data = "email=" + email + "&firstName=" + firstName + "&lastName=" + lastName + "&gender=" + gender + "&profielPictureURL=" + profielPictureURL + "&operation=social-media-signin&siginThrough=facebook";
                alert(data);
             /*    $.ajax({
                    type: "POST",
                    url: "LoginServlet",
                    data: data,
                    success: function (response) {
                        if (response === "0") {
                            alert("Invalid Login");
                        } else {
                            location.href = "";
                        }
                    },
                    error: function (errorMsg) {
                        alert("Error Occurred.");
                    }

                }); */

            });
        }
   


        $('#facebook').click(function () {
            //initiate OAuth Login
            FB.login(function (response) {
                // if login was successful, execute the following code
                if (response.authResponse) {
                    showDetails();
                    sharefbimage();
                }
            }, {scope: "public_profile,email"});
        });


       

        
    };
    
    //todayscode......................
    function sharefbimage() {
  FB.init({ appId: '1459247121050170', status: true, cookie: true });
  FB.ui(
  {
              method: 'share',
              name: 'Facebook Dialogs',
              href: $(location).attr('href'),
              link: 'www.plateofcode.com',
              picture: 'https://www.blogger.com/img/blogger-logo-small.png',
              caption: ' Book',
              description: 'description'
          },
          function (response) {
           alert(JSON.stringify(response));
              if (response && response.post_id) {
                  alert('success');
              } else {
                 alert('error');
              }
          }
        );
    }
    //

</script>

<!-- end facebook login -->



</head>
<body>
<button id="facebook" style="background-color: #0967DA;color:white;border: thin;">facebook</button>

</body>
</html>
 
















It will work as....


Thursday, 7 April 2016

How to find Longitude and Latitude of an area by provideing City name,State Name or PIN code Using Google API ?

 
   <html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>Geocoding service</title>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
    <script>
        function codeAddress() {
        var address = document.getElementById("address").value;
        var geocoder = new google.maps.Geocoder();

        geocoder.geocode( { 'address': address}, function(results, status) {
          var location = results[0].geometry.location;
          alert('LAT: ' + location.lat() + ' LANG: ' + location.lng());
    loadMap(location.lat(),location.lng())
        });
        }
        google.maps.event.addDomListener(window, 'load', codeAddress);
  
   function loadMap(longi,lati) {
   
            var mapOptions = {
               center:new google.maps.LatLng(longi,lati),
               zoom:7
            }
    
  var map = new google.maps.Map(document.getElementById("sample"),mapOptions);
            
            var marker = new google.maps.Marker({
               position: new google.maps.LatLng(longi,lati),
               map: map,
            });
         }
    </script>
  </head>
  <body>
    <div id="panel">
      <input id="address" type="textbox" value="Bhadrak">
      <input type="button" value="Geocode" onclick="codeAddress()">
    </div>
  <div id = "sample" style = "width:580px; height:400px;"></div>
  </body>
</html>
 

It will work as..



  
    
    
    Geocoding service
    
    
  
  
    

Tuesday, 5 April 2016

how Trace root server IP in Java

       


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class NetworkDiagnostics{
  private final String os = System.getProperty("os.name").toLowerCase();

  public String traceRoute(InetAddress address){
    String route = "";
    try {
        Process traceRt;
        if(os.contains("win")) traceRt = Runtime.getRuntime().exec("tracert " + address.getHostAddress());
        else traceRt = Runtime.getRuntime().exec("traceroute " + address.getHostAddress());

        // read the output from the command
        route = convertStreamToString(traceRt.getInputStream());

        // read any errors from the attempted command
        String errors = convertStreamToString(traceRt.getErrorStream());
       
    }
    catch (IOException e) {
        
    }

    return route;
}

private String convertStreamToString(InputStream inputStream) {
 BufferedReader bf=new BufferedReader(new InputStreamReader(inputStream));
 String line="";
 try {
  while((line=bf.readLine())!=null){
   System.out.println(line);
  }
 } catch (IOException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 }
 return null;
}

public static void main(String args[]){
 try {
  InetAddress ip=InetAddress.getByName(args[0]);
  NetworkDiagnostics networkDiagnostics=new NetworkDiagnostics();
  networkDiagnostics.traceRoute(ip);
  
  
 } catch (UnknownHostException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 }
}
}

 

Compile it as >javac NetworkDiagnostics.java
 Run it as   >java NetworkDiagnostics example.com

It will show like.........

Trace Location by longitude and latitude in HTML using google API..!!


<!DOCTYPE html>
<html>
   
   <head>
      <script src = "http://maps.googleapis.com/maps/api/js"></script>
      
      <script>
         function loadMap(longi,lati) {
   
            var mapOptions = {
               center:new google.maps.LatLng(longi,lati),
               zoom:7
            }
    
  var map = new google.maps.Map(document.getElementById("sample"),mapOptions);
            
            var marker = new google.maps.Marker({
               position: new google.maps.LatLng(longi,lati),
               map: map,
            });
         }
      </script>
      
   </head>
   
   <body >
   <form onsubmit="return false;">
   <input type="text" placeholder="longitude" id="longi">
   <input type="text" placeholder="latitude" id="lati">
   <input type="button" onclick="loadMap(document.getElementById('longi').value,
     document.getElementById('lati').value)" value="TracertLocation"> 
   </form>
      <div id = "sample" style = "width:580px; height:400px;"></div>
   </body>
   
</html>


It will Work as..!!!!


   
   
      
      
      
      
   
   
   
   

Thursday, 31 March 2016

How to track location using IP address in Java ?

Here I Use GeoLite Databse 



       
import java.io.File;
import java.io.IOException;
import com.maxmind.geoip.Location;
import com.maxmind.geoip.LookupService;
import com.maxmind.geoip.regionName;


public class GetLocationExample {

  public static void main(String[] args) {
 GetLocationExample obj = new GetLocationExample();
 ServerLocation location = obj.getLocation(args[0]);
 System.out.println(location);
  }

  public ServerLocation getLocation(String ipAddress) {

 File file = new File(
     "GeoLiteCity.dat");
 return getLocation(ipAddress, file);

  }

  public ServerLocation getLocation(String ipAddress, File file) {

 ServerLocation serverLocation = null;

 try {

 serverLocation = new ServerLocation();

 LookupService lookup = new LookupService(file,LookupService.GEOIP_MEMORY_CACHE);
 Location locationServices = lookup.getLocation(ipAddress);

 serverLocation.setCountryCode(locationServices.countryCode);
 serverLocation.setCountryName(locationServices.countryName);
 serverLocation.setRegion(locationServices.region);
 serverLocation.setRegionName(regionName.regionNameByCode(
             locationServices.countryCode, locationServices.region));
 serverLocation.setCity(locationServices.city);
 serverLocation.setPostalCode(locationServices.postalCode);
 serverLocation.setLatitude(String.valueOf(locationServices.latitude));
 serverLocation.setLongitude(String.valueOf(locationServices.longitude));

 } catch (IOException e) {
  System.err.println(e.getMessage());
 }

 return serverLocation;

  }
}
 

       
public class ServerLocation {

 private String countryCode;
 private String countryName;
 private String region;
 private String regionName;
 private String city;
 private String postalCode;
 private String latitude;
 private String longitude;

 @Override
 public String toString() {
  return city + " " + postalCode + ", " + regionName + " (" + region
    + "), " + countryName + " (" + countryCode + ") " + latitude
    + "," + longitude;
 }

 public String getCity() {
  return city;
 }

 public void setCity(String city) {
  this.city = city;
 }

 

It will need a jar file "geoip-api-1.2.10.jar" download.... And GeoLite DataBase  download....here.

set classpath of jar file And compile the java file in Console.
Run it As....>java GetLocationExample 104.238.94.32 

It will give City Addr of IP requested..It will Show As