Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Wednesday, 24 June 2015

Access client machine printer using PrinterJob in Oracle ADF

Hi Folks this post is about accessing client machine printer using java PrinterJob in ADF application. Sometimes we may get requirement to handle windows printer like "Direct printing without print dialog box". You cannot customize the windows printer.
By using the Java PrinterJob you can completely handle print dialog and its properties from java. For more information on java PritnerJob check this
This can be achieved using Applet integration in ADF page.  For applet integration in ADF page go through my previous post Get Client machine MAC address in ADF using applet

Follow same steps given in my previous post.
In Messageapplet class add the following java code



Build the jar file and integrate in adf  project. Below is java script call the applet method on button click.


Run the jspx page. Print dialog is of java not windows print dialog.


Download here
Cheers :) Happy Learning :)


Monday, 22 June 2015

Get Client machine MAC address in ADF using applet

Hi folks in this post i will show you how to get client machine MAC address in ADF page using applet.
Step1: Create Generic application. and create java class which extends JApplet.

Step2:  Add the below shown java code. This code use to read the client machine MAC address.




Step 3: Create JAR file for this project and sign the jar file. This link will hep you to sign the jar

Step 4: Create Fusion Web application and add the jar file in public_html folder as shown below




Step 5: Now create jspx page with one button. When you click on button the MAC address displays in POP up. Using javascript will call the applet code and get the mac address.



Step6: Run the jspx page and click on get client mac address button



You can download the code using the link Download

Thanks:) Happy learning:)





Tuesday, 11 September 2012

Date Format example in java


import java.text.*;
import java.util.*;

public class DateFormat {

  public static void main(String args[]) {

  String s;
  Format formatter;
  Date date = new Date();

  // 01/09/02
  formatter = new SimpleDateFormat("MM/dd/yy");
  s = formatter.format(date);
  System.out.println(s);

  // 01/09/02
  formatter = new SimpleDateFormat("dd/MM/yy");
  s = formatter.format(date);
  System.out.println(s);

  // 29-Jan-02
  formatter = new SimpleDateFormat("dd-MMM-yy");
  s = formatter.format(date);
  System.out.println(s);

  // 2002.01.29.08.36.33
  formatter = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
  s = formatter.format(date);
  System.out.println(s);

  // Tue, 09 Jan 2002 22:14:02 -0500
  formatter = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z");
  s = formatter.format(date);
  System.out.println(s);

  formatter = new SimpleDateFormat("EEEE, dd MMMM yyyy HH:mm:ss zzzz");
  s = formatter.format(date);
  System.out.println(s);
  }
}

Creating file in java



Following code is to create file "testfile.txt" in current directory.

import java.io.*;

public class SampleFile{
  public static void main(String[] args) throws IOException{
  File f=new File("testfile.txt");
  if(!f.exists()){
  f.createNewFile();
  System.out.println("New file \"myfile.txt\" has been created 
  to the current directory");
  }
  }
}

Monday, 10 September 2012

Convert java.util.Date to java.sql.Date

import java.sql.Date;
class sqlDate
{


//Method to convert  java.util.Date to java.sql.Date

public static Date UtilDateToSqlDate(java.util.Date utilDate) {
  Date sqlDate = null;
  if (utilDate != null)  sqlDate = new Date(utilDate.getTime());
  return sqlDate;
 }

// Method to convert java.sql.Date to java.util.Date

 public static java.util.Date SqlDateToUtilDate(Date sqlDate) {
  java.util.Date utilDate = null;
  if (sqlDate != null)  utilDate = new java.util.Date(sqlDate.getTime());
  return utilDate;
 }


public static void main(String args[])

{
java.util.Date d1 = new java.util.Date();
  System.out.println("Util Date : "+ d1);


java.sql.Date d2 =UtilDateToSqlDate(d1);
  System.out.println("Sql Date : " + d2);



java.util.Date d3= SqlDateToUtilDate(d2);
  System.out.println("Back to Util Date : "+ d3);
}


}