How to generate key pair using java ?(its urgent)

We r working on java card. For security purpose I want a Key pair.
If anyone is able to uide me by giving me a small code or algorithm i am very thankful.
Its an urgent !!!!
Plz inform me if any relative information u r having.

import java.security.KeyPairGenerator;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.KeyFactory;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.io.FileOutputStream;
import java.io.FileInputStream;
public class ParClaves {
     public KeyPairGenerator keyPairGenerator;
     public KeyPair keyPair;
     public PrivateKey privateKey;
     public PublicKey publicKey;
     public String algoritmo = "DSA"; // DSA o RSA
     public String proveedor = null;
     public int keysize = 1024;
     public SecureRandom random = null;
     public void guardarClaves(String fichClavePublica, String fichClavePrivada) throws Exception {
          byte[] key = this.publicKey.getEncoded();
          FileOutputStream keyfos = new FileOutputStream(fichClavePublica);
          keyfos.write(key);
          keyfos.close();               
          key = this.privateKey.getEncoded();
          keyfos = new FileOutputStream(fichClavePrivada);
          keyfos.write(key);
          keyfos.close();               
     } // fin de guardarClaves
     public void guardarClaves(String fichClavePublica, String fichClavePrivada, KeyPair keyPair) throws Exception {
          byte[] key = keyPair.getPublic().getEncoded();
          FileOutputStream keyfos = new FileOutputStream(fichClavePublica);
          keyfos.write(key);
          keyfos.close();               
          key = keyPair.getPrivate().getEncoded();
          keyfos = new FileOutputStream(fichClavePrivada);
          keyfos.write(key);
          keyfos.close();               
     } // fin de guardarClaves     
     public KeyPair recuperarClaves(String fichClavePublica, String fichClavePrivada) throws Exception {
          return new KeyPair(recuperarClavePublica(fichClavePublica), recuperarClavePrivada(fichClavePrivada));
     } // fin de recuperarClaves
     public PublicKey recuperarClavePublica(String fichClavePublica) throws Exception {
// PENDIENTE: seguramente, para que esto fuera v�lido, habr�a que proporcionar el Proveedor ?�
// probar generando clavePublica con otro proveedor distinto de SUN
          FileInputStream fis = new FileInputStream(fichClavePublica);
          byte[] encKey = new byte[fis.available()];
          fis.read(encKey);
          fis.close();
          KeyFactory keyFactory = null;
          try {
               keyFactory = KeyFactory.getInstance("DSA");
          } catch (Exception e) {
               keyFactory = KeyFactory.getInstance("RSA");
          } // fin del try
          X509EncodedKeySpec pubKeySpecX509 = new X509EncodedKeySpec(encKey);
          PublicKey publicKey = keyFactory.generatePublic(pubKeySpecX509);
          return publicKey;
     } // fin de recuperarClavePublica
     public PrivateKey recuperarClavePrivada(String fichClavePrivada) throws Exception {
// PENDIENTE: seguramente, para que esto fuera v�lido, habr�a que proporcionar el Proveedor ?�
// probar generando clavePrivada con otro proveedor distinto de SUN
          FileInputStream fis = new FileInputStream(fichClavePrivada);
          byte[] encKey = new byte[fis.available()];
          fis.read(encKey);
          fis.close();
          KeyFactory keyFactory = null;
          try {
               keyFactory = KeyFactory.getInstance("DSA");
          } catch (Exception e) {
               keyFactory = KeyFactory.getInstance("RSA");
          } // fin del try
          PKCS8EncodedKeySpec privKeySpecPKCS8 = new PKCS8EncodedKeySpec(encKey);
          PrivateKey privateKey = keyFactory.generatePrivate(privKeySpecPKCS8);
          return privateKey;
     } // fin de recuperarClavePrivada
     public KeyPair generarClaves() throws Exception {
          if (this.proveedor == null) {
               this.keyPairGenerator = KeyPairGenerator.getInstance(this.algoritmo);
               this.proveedor = this.keyPairGenerator.getProvider().getName();
          } else {
               this.keyPairGenerator = KeyPairGenerator.getInstance(this.algoritmo, this.proveedor);
          } // fin del if
          if (this.random == null) {
               this.keyPairGenerator.initialize(this.keysize);
          } else {
               this.keyPairGenerator.initialize(this.keysize, this.random);
          } // fin del if
          this.keyPair = this.keyPairGenerator.generateKeyPair();
          this.privateKey = this.keyPair.getPrivate();
          this.publicKey = this.keyPair.getPublic();
          return this.keyPair;
     } // fin de generarClaves
     public KeyPair generarClaves(SecureRandom random) throws Exception {
          this.random = random;
          return generarClaves();
     } // fin de generarClaves
     public KeyPair generarClaves(int keysize) throws Exception {
          this.keysize = keysize;
          return generarClaves();
     } // fin de generarClaves
     public KeyPair generarClaves(int keysize, SecureRandom random) throws Exception {
          this.keysize = keysize;
          this.random = random;          
          return generarClaves();
     } // fin de generarClaves
     public KeyPair generarClaves(String algoritmoOproveedor) throws Exception {
          decidir(algoritmoOproveedor);
          return generarClaves();
     } // fin de generarClaves
     public KeyPair generarClaves(String algoritmoOproveedor, SecureRandom random) throws Exception {
          decidir(algoritmoOproveedor);
          this.random = random;          
          return generarClaves();
     } // fin de generarClaves
     public KeyPair generarClaves(String algoritmoOproveedor, int keysize) throws Exception {
          decidir(algoritmoOproveedor);
          this.keysize = keysize;          
          return generarClaves();
     } // fin de generarClaves
     public KeyPair generarClaves(String algoritmoOproveedor, int keysize, SecureRandom random) throws Exception {
          decidir(algoritmoOproveedor);
          this.keysize = keysize;          
          this.random = random;                    
          return generarClaves();
     } // fin de generarClaves
     public KeyPair generarClaves(String algoritmo, String proveedor) throws Exception {
          this.algoritmo = algoritmo;          
          this.proveedor = proveedor;                    
          return generarClaves();
     } // fin de generarClaves
     public KeyPair generarClaves(String algoritmo, String proveedor, SecureRandom random) throws Exception {
          this.algoritmo = algoritmo;          
          this.proveedor = proveedor;
          this.random = random;                              
          return generarClaves();
     } // fin de generarClaves
     public KeyPair generarClaves(String algoritmo, String proveedor, int keysize) throws Exception {
          this.algoritmo = algoritmo;          
          this.proveedor = proveedor;
          this.keysize = keysize;                              
          return generarClaves();
     } // fin de generarClaves
     public KeyPair generarClaves(String algoritmo, String proveedor, int keysize, SecureRandom random) throws Exception {
          this.algoritmo = algoritmo;          
          this.proveedor = proveedor;
          this.keysize = keysize;
          this.random = random;          
          return generarClaves();
     } // fin de generarClaves
     public String getInformacion() {
          StringBuffer sb = new StringBuffer();
          sb.append("Algoritmo: " + this.algoritmo + "\n");
          sb.append("Proveedor: " + this.proveedor + "\n");
          sb.append("Keysize: " + this.keysize + "\n");
          return sb.toString();
     } // fin de getInformacion
     public boolean esAlgoritmoValido(String algoritmo) {
          try {
               KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(algoritmo);
               return true;
          } catch (Exception e) {
               return false;
          } // fin del try
     } // fin de esAlgoritmoValido
     private void decidir(String algoritmoOproveedor) {
          if (esAlgoritmoValido(algoritmoOproveedor)) {
               this.algoritmo = algoritmoOproveedor;
          } else {
               this.proveedor = algoritmoOproveedor;
          } // fin del if
     } // fin de decidir
} // fin de ParClaves

Similar Messages

  • How to generate Serial numbers using JAVA SCRIPT

    how to generate serial numbers(incrementing by 1) using JAVA SCRIPT
    thanking you,
    pola pradeep

    i am afraid that whether ur looking for this. bcoz its a simple for loop
    <script language="JavaScript">
    //count = limit value for u
    for(i=0;i<count;++i){
         alert(i);
    </script>
    or if ur looking for something else, pls mention ur requrment precisely
    aleena

  • How to indetify key pair in Java?

    Hello
    I need only to know if some private and public key generating one key pair.
    I don't want to try it through encrypt/decrypt process and checking data.
    Thanks

    I have some private key and some public key and I need to detect if private key belongs to some public key. It shouldn't be possible to get into such a state in the first place. Key pairs should be stored in such a way that they are always together, e.g. in a java.security.KeyStore or an HSM, most probably associated with a Certificate.
    If true, then I can encrypt data by one of them and correctly decrypt by second.You can encrypt with the public key and decrypt with the private key.
    If false ,I will got incorrect data after decryption.No you won't, you'll get an exception.

  • How to generate soap header using java code

    Hi,
    I need to generate the following soap header using java DOM.
    Can you send me some java code snippet to do so?
    <soapenv:Header>
    <api:RequesterCredentials soapenv:mustUnderstand="0" xmlns:api="urn:ThinkPod:api:ThinkPodAPI" xmlns:ebl="urn:ThinkPod:apis:eBLBaseComponents">
    <ebl:ThinkPodAuthToken>YourToken</ebl:ThinkPodAuthToken>
    <ebl:Credentials>
    <ebl:DevId>YourDevId</ebl:DevId>
    <ebl:AppId>YourAppId</ebl:AppId>
    <ebl:AuthCert>YourAuthCert</ebl:AuthCert>
    </ebl:Credentials>
    </api:RequesterCredentials>
    </soapenv:Header>

    You want to generate that on a mobile device or how is that related to CLDC and MIDP?

  • How to generate reportdesign dynamically using java with out xml file

    hi
    how can i generate a reportdesign dynamically using java with out passing xml file to jasperDesign , i want to create my reportdesign with out xml file
    how can i ,please help
    thanks

    LiveCycle does provide a Java API to forms; LiveCycle is in fact a suite of programs, mostly enterprise level for running on server (next to which the cost of the master suite is a drop in the ocean). LiveCycle Designer is perhaps the only end user tool, and it is not for server use and doesn't have an API.
    Are you looking for a server solution? If so, nothing in the master suite can help, it isn't for server use.

  • Generating key pair on PKCS#11token and save it there

    Hello,
    again i'm completely lost in this PKCS11 jungle.
    What i want to do:
    Generating key pair on crypto pkcs11 token and store it there.
    In the moment i've tried eg:
    sun.security.pkcs11.SunPKCS11 p = new sun.security.pkcs11.SunPKCS11(configName);
    Security.addProvider(p);
    Builder builder = KeyStore.Builder.newInstance("PKCS11", p, new KeyStore.CallbackHandlerProtection(new UserInputDialog(new JDialog(),"test","test")));
    KeyStore ks = builder.getKeyStore();
    ks.load(null,null);
    KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA", p);
    gen.initialize(1024);
    KeyPair kp = gen.generateKeyPair();
               Here access to token works. The callback PIN dialog comes up and i can login.
    But i'm not sure whether the key are generated on this PKCS11. And they are not stored there.
    How i can generate keys are stored there.
    (like with keytool -genkeys ). In keytool case a certificate is stored.
    ... every little hint, also to some documentation i've not seen, is very welcome ...
    Thank You !
    Regards
    Thomas
    .

    First, you need to get a KeyStore representation of the PKCS#11 token with code similar to this, I'm using NSS as the PKCS#11 token in this example:
    Provider nss = new sun.security.pkcs11.SunPKCS11(configFile);
    Security.insertProviderAt(nss, 1);  //you may not want it at highest priority
    KeyStore ks = KeyStore.getInstance("PKCS11", nss);
    ks.load(null, password);From the testing I've done in the past with various tokens, when you generate an asymmetric keypair (e.g. RSA like you are) specifying the PKCS11 provider, it creates it right on the token automatically and code like below is not needed.
    To store the key in the keystore, use code similar to this, I'm using NSS again and storing a symmetric key:
    KeyGenerator kg = KeyGenerator.getInstance("DESede",nss);
    SecretKey tripleDesKey = kg.generateKey();
    KeyStore.SecretKeyEntry skEntry = new KeyStore.SecretKeyEntry(tripleDesKey);
    ks.setEntry(randAlias, skEntry, new KeyStore.PasswordProtection(password));

  • How to set proxy authentication using java properties at run time

    Hi All,
    How to set proxy authentication using java properties on the command line, or in Netbeans (Project => Properties
    => Run => Arguments). Below is a simple URL data extract program which works in absence of firewall:
    import java.io.*;
    import java.net.*;
    public class DnldURLWithoutUsingProxy {
       public static void main (String[] args) {
          URL u;
          InputStream is = null;
          DataInputStream dis;
          String s;
          try {
              u = new URL("http://www.yahoo.com.au/index.html");
             is = u.openStream();         // throws an IOException
             dis = new DataInputStream(new BufferedInputStream(is));
             BufferedReader br = new BufferedReader(new InputStreamReader(dis));
          String strLine;
          //Read File Line By Line
          while ((strLine = br.readLine()) != null)      {
          // Print the content on the console
              System.out.println (strLine);
          //Close the input stream
          dis.close();
          } catch (MalformedURLException mue) {
             System.out.println("Ouch - a MalformedURLException happened.");
             mue.printStackTrace();
             System.exit(1);
          } catch (IOException ioe) {
             System.out.println("Oops- an IOException happened.");
             ioe.printStackTrace();
             System.exit(1);
          } finally {
             try {
                is.close();
             } catch (IOException ioe) {
    }However, it generated the following message when run behind the firewall:
    cd C:\Documents and Settings\abc\DnldURL\build\classes
    java -cp . DnldURLWithoutUsingProxy
    Oops- an IOException happened.
    java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
    at java.net.Socket.connect(Socket.java:452)
    at java.net.Socket.connect(Socket.java:402)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
    at sun.net.www.http.HttpClient.New(HttpClient.java:339)
    at sun.net.www.http.HttpClient.New(HttpClient.java:320)
    at sun.net.www.http.HttpClient.New(HttpClient.java:315)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:510)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:487)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:615) at java.net.URL.openStream(URL.java:913) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
    I have also tried the command without much luck either:
    java -cp . -Dhttp.proxyHost=wwwproxy -Dhttp.proxyPort=80 DnldURLWithoutUsingProxy
    Oops- an IOException happened.
    java.io.IOException: Server returned HTTP response code: 407 for URL: http://www.yahoo.com.au/index.html
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245) at java.net.URL.openStream(URL.java:1009) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
    All outgoing traffic needs to use the proxy wwwproxy (alias to http://proxypac/proxy.pac) on port 80, where it will prompt for valid authentication before allowing to get through.
    There is no problem pinging www.yahoo.com from this system.
    I am running jdk1.6.0_03, Netbeans 6.0 on Windows XP platform.
    I have tried Greg Sporar's Blog on setting the JVM option in Sun Java System Application Server (GlassFish) and
    Java Control Panel - Use browser settings without success.
    Thanks,
    George

    Hi All,
    How to set proxy authentication using java properties on the command line, or in Netbeans (Project => Properties
    => Run => Arguments). Below is a simple URL data extract program which works in absence of firewall:
    import java.io.*;
    import java.net.*;
    public class DnldURLWithoutUsingProxy {
       public static void main (String[] args) {
          URL u;
          InputStream is = null;
          DataInputStream dis;
          String s;
          try {
              u = new URL("http://www.yahoo.com.au/index.html");
             is = u.openStream();         // throws an IOException
             dis = new DataInputStream(new BufferedInputStream(is));
             BufferedReader br = new BufferedReader(new InputStreamReader(dis));
          String strLine;
          //Read File Line By Line
          while ((strLine = br.readLine()) != null)      {
          // Print the content on the console
              System.out.println (strLine);
          //Close the input stream
          dis.close();
          } catch (MalformedURLException mue) {
             System.out.println("Ouch - a MalformedURLException happened.");
             mue.printStackTrace();
             System.exit(1);
          } catch (IOException ioe) {
             System.out.println("Oops- an IOException happened.");
             ioe.printStackTrace();
             System.exit(1);
          } finally {
             try {
                is.close();
             } catch (IOException ioe) {
    }However, it generated the following message when run behind the firewall:
    cd C:\Documents and Settings\abc\DnldURL\build\classes
    java -cp . DnldURLWithoutUsingProxy
    Oops- an IOException happened.
    java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
    at java.net.Socket.connect(Socket.java:452)
    at java.net.Socket.connect(Socket.java:402)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
    at sun.net.www.http.HttpClient.New(HttpClient.java:339)
    at sun.net.www.http.HttpClient.New(HttpClient.java:320)
    at sun.net.www.http.HttpClient.New(HttpClient.java:315)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:510)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:487)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:615) at java.net.URL.openStream(URL.java:913) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
    I have also tried the command without much luck either:
    java -cp . -Dhttp.proxyHost=wwwproxy -Dhttp.proxyPort=80 DnldURLWithoutUsingProxy
    Oops- an IOException happened.
    java.io.IOException: Server returned HTTP response code: 407 for URL: http://www.yahoo.com.au/index.html
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245) at java.net.URL.openStream(URL.java:1009) at DnldURLWithoutUsingProxy.main(DnldURLWithoutUsingProxy.java:17)
    All outgoing traffic needs to use the proxy wwwproxy (alias to http://proxypac/proxy.pac) on port 80, where it will prompt for valid authentication before allowing to get through.
    There is no problem pinging www.yahoo.com from this system.
    I am running jdk1.6.0_03, Netbeans 6.0 on Windows XP platform.
    I have tried Greg Sporar's Blog on setting the JVM option in Sun Java System Application Server (GlassFish) and
    Java Control Panel - Use browser settings without success.
    Thanks,
    George

  • How to implement route cipher using java?

    Hi guys,,,
    I really got a headache solving how to implement route cipher using java lang,,i already got the concept but i really dont get how to implement it using java actually i want to make a presentation of how route cipher works using "adobe flash" but first i will implement it using java coz flash actionscripts are closer to java lang.
    Hope you could post some examples or ideas...i would really appreciate it!
    thank you so much...

    just add an action listener (either keypressed or keytyped) to the frame that you want to record. I did this in NetBeans in about 2 seconds. I can simplify it if you need. As for loging it just write the characters to a file output stream.
    public class test extends javax.swing.JFrame {
        /** Creates new form test */
        public test() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
        private void initComponents() {
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            addKeyListener(new java.awt.event.KeyAdapter() {
                public void keyTyped(java.awt.event.KeyEvent evt) {
                    formKeyTyped(evt);
            pack();
        // </editor-fold>
        private void formKeyTyped(java.awt.event.KeyEvent evt) {
            System.out.println(evt.getKeyChar());
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new test().setVisible(true);
        // Variables declaration - do not modify
        // End of variables declaration
    }

  • How to send mail attachments using java mail

    can any one help how to create mails attachments using java mail

    you can do it like this:
    Message msg = new MimeMessage(session);
    String fileAttachment = "c:/test.txt";
    Multipart mp = new MimeMultipart();
    BodyPart bp = new MimeBodyPart();
    FileDataSource fds = new FileDataSource(fileAttachment);
    bp.setDataHandler(new DataHandler(fds));
    bp.setFileName(fds.getName());
    mp.addBodyPart(bp);
    msg.setContent(mp);
    ...

  • How to generate key events programmatically

    Hello friends,
    I am developing an application that would automaticall trigger some keboard events for this purpose i would like to trigger an event like alt+f4 i.e pressing alt+f4 together
    How can we do this using java
    regards
    hari

    You should be able to use the java.awt.Robot class to perform programmatic UI events.
    It doesn't seem that it permits use to do things like keyPress("alt-f4") so you might have to do something like this:
    Robot robot = new Robot();
    robot.keyPress(KeyEvent.VK_ALT);
    robot.keyPress(KeyEvent.VK_F4);
    robot.keyRelease(KeyEvent.VK_F4);
    robot.keyRelease(KeyEvent.VK_ALT);Hope this helps.

  • How to generate addm report using grid

    Hi,
    how to generate addm report using grid, please provide any relevant doc/links etc.
    Thanks in advance.

    how to generate addm report using grid, please provide any relevant doc/links etc.When you start with the wrong question, no matter how good an answer you get, it won't matter very much.
    what is best way to divide board into 2 pieces using a hammer?
    Edited by: sb92075 on Oct 25, 2010 7:22 AM

  • How to read system eventlog using java program in windows?

    How to read system eventlog using java program in windows?
    is there any java class available to do this ? or any one having sample code for this?
    Your friend Zoe

    Hi,
    There is no java class for reading event log in windows, so we can do one thing we can use windows system 32 VBS script to read the system log .
    The output of this command can be read using java program....
    we can use java exec for executing this system32 vbs script.
    use the below program and pass the command "eventquery"
    plz refer cscript,wscript
    import java.io.*;
    public class CmdExec {
    public static void main(String argv[]) {
    try {
    String line;
    Process p = Runtime.getRuntime().exec("Command");
    BufferedReader input =
    new BufferedReader
    (new InputStreamReader(p.getInputStream()));
    while ((line = input.readLine()) != null) {
    System.out.println(line);
    input.close();
    catch (Exception err) {
    err.printStackTrace();
    This sample program will list all the system log information....
    Zoe

  • How to read system evenlog using java program in windows

    How to read system evenlog using java program in windows???
    is there any java class available to do this ? or any one having sample code for this?
    Your friend Zoe

    Welcome to the Sun forums.
    >
    How to read system evenlog using java program in windows???>
    JNI. (No.)
    >
    is there any java class available to do this ? or any one having sample code for this?>You will generally get better help around here if you read the documentation, try some sample code and come back with a specific question (hopefully with an SSCCE included).
    >
    Your friend Zoe>(raised eyebrow) Thank you for sharing that with us.
    Note also that one '?' denotes a question, while 2 or more generally denotes a dweeb.

  • How to run .jar on linux & how to create .jar file using java?

    hi, may i know how to run .jar on linux & how to create .jar file using java? Can u provide the steps on doing it.
    thanks in advance.

    Look at the manual page for jar:
    # man jar
    Also you can run them by doing:
    # java -jar Prog.jar

  • How to print PDF files using java print API

    Hi,
    I was goign throw lot of discusion and reading lot of forums related to print pdf files using java api. but nothing seems to be working for me. Can any one tell me how to print pdf files using java api.
    Thanks in advance

    Mike,
    Can't seem to get hold of the example described in your reply below. If you could let us have the URL to get then it would be great.
    My GUI application creates a pdf document which I need to print. I want to achieve this using the standard Java class PrinterJob (no 3rd party APIs I'm afraid, commercial restraints etc ..). I had a stab at it using the following code. When executed I get the pretty printer dialog then when I click ok to print, nothing happens!
    boolean showPrintDialog=true;
    PrinterJob printJob = PrinterJob.getPrinterJob ();
    printJob.setJobName ("Contract.pdf");
    try {
    if (showPrintDialog) {
    if (printJob.printDialog()) {
    printJob.print();
    else
    printJob.print ();
    } catch (Exception PrintException) {
                   PrintException.printStackTrace();
    Thank you and a happy new year.
    Cheers,
    Chris

Maybe you are looking for