How to sign the applet with verisign certificate?

Hi,
I got a test certificate from the Verisign.
Now I want to know, how to sign my applet with that certificate?
Thanks,
Siva E.

Hi!
You have to create a keystore wich contains the certificate. I think you call keystore -import "verisign.cert"Try the command, and it will tell you what it needs.
To do the acutal signing of an applet (jar-file), you write somehting like this:
jarsigner  -keystore "NameOfKeystore" -keypass "PasswordToPrivKey"  -storepass "PasswordToStore" "YourJarFile.jar" "CertAlias"The cert alias is an alias you created when importing the certificate. Hope it Helps!
Henrik

Similar Messages

  • How to sign the data with DHPrivateKey

    I am testing DH key exchange protocol. When I run the following code, it works.
    import java.io.*;
    import java.math.BigInteger;
    public class DH2 {
        private DH2() {}
        public static void main(String argv[]) {
            try {
                String mode = "USE_SKIP_DH_PARAMS";
                DH2 keyAgree = new DH2();
                if (argv.length > 1) {
                    keyAgree.usage();
                    throw new Exception("Wrong number of command options");
                } else if (argv.length == 1) {
                    if (!(argv[0].equals("-gen"))) {
                        keyAgree.usage();
                        throw new Exception("Unrecognized flag: " + argv[0]);
                    mode = "GENERATE_DH_PARAMS";
                keyAgree.run(mode);
            } catch (Exception e) {
                System.err.println("Error: " + e);
                System.exit(1);
        private void run(String mode) throws Exception {
            DHParameterSpec dhSkipParamSpec;
            if (mode.equals("GENERATE_DH_PARAMS")) {
                // Some central authority creates new DH parameters
                System.out.println
                    ("Creating Diffie-Hellman parameters (takes VERY long) ...");
                AlgorithmParameterGenerator paramGen
                    = AlgorithmParameterGenerator.getInstance("DH");
                paramGen.init(512);
                AlgorithmParameters params = paramGen.generateParameters();
                dhSkipParamSpec = (DHParameterSpec)params.getParameterSpec
                    (DHParameterSpec.class);
            } else {
                // use some pre-generated, default DH parameters
                System.out.println("Using SKIP Diffie-Hellman parameters");
                dhSkipParamSpec = new DHParameterSpec(skip1024Modulus,
                                                      skip1024Base);
            System.out.println("ALICE: Generate DH keypair ...");
            KeyPairGenerator aliceKpairGen = KeyPairGenerator.getInstance("DH");
            aliceKpairGen.initialize(dhSkipParamSpec);
            KeyPair aliceKpair = aliceKpairGen.generateKeyPair();
            System.out.println("ALICE: Initialization ...");
            KeyAgreement aliceKeyAgree = KeyAgreement.getInstance("DH");
            aliceKeyAgree.init(aliceKpair.getPrivate());
            byte[] alicePubKeyEnc = aliceKpair.getPublic().getEncoded();
            KeyFactory bobKeyFac = KeyFactory.getInstance("DH");
            X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec
                (alicePubKeyEnc);
            PublicKey alicePubKey = bobKeyFac.generatePublic(x509KeySpec);
            DHParameterSpec dhParamSpec = ((DHPublicKey)alicePubKey).getParams();
            System.out.println("BOB: Generate DH keypair ...");
            KeyPairGenerator bobKpairGen = KeyPairGenerator.getInstance("DH");
            bobKpairGen.initialize(dhParamSpec);
            KeyPair bobKpair = bobKpairGen.generateKeyPair();
            System.out.println("BOB: Initialization ...");
            KeyAgreement bobKeyAgree = KeyAgreement.getInstance("DH");
            bobKeyAgree.init(bobKpair.getPrivate());
            byte[] bobPubKeyEnc = bobKpair.getPublic().getEncoded();
            KeyFactory aliceKeyFac = KeyFactory.getInstance("DH");
            x509KeySpec = new X509EncodedKeySpec(bobPubKeyEnc);
            PublicKey bobPubKey = aliceKeyFac.generatePublic(x509KeySpec);
            System.out.println("ALICE: Execute PHASE1 ...");
            aliceKeyAgree.doPhase(bobPubKey, true);
            System.out.println("BOB: Execute PHASE1 ...");
            bobKeyAgree.doPhase(alicePubKey, true);
            byte[] aliceSharedSecret = aliceKeyAgree.generateSecret();
            int aliceLen = aliceSharedSecret.length;
            byte[] bobSharedSecret = new byte[aliceLen];
            int bobLen;
            try {
                bobLen = bobKeyAgree.generateSecret(bobSharedSecret, 1);
            } catch (ShortBufferException e) {
                System.out.println(e.getMessage());
            bobLen = bobKeyAgree.generateSecret(bobSharedSecret, 0);
            System.out.println("Alice secret: " +
              toHexString(aliceSharedSecret));
            System.out.println("Bob secret: " +
              toHexString(bobSharedSecret));
            if (!java.util.Arrays.equals(aliceSharedSecret, bobSharedSecret))
                throw new Exception("Shared secrets differ");
            System.out.println("Shared secrets are the same");
            System.out.println("Return shared secret as SecretKey object ...");
            bobKeyAgree.doPhase(alicePubKey, true);
            SecretKey bobDesKey = bobKeyAgree.generateSecret("DES");
            aliceKeyAgree.doPhase(bobPubKey, true);
            SecretKey aliceDesKey = aliceKeyAgree.generateSecret("DES");
            Cipher bobCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
            bobCipher.init(Cipher.ENCRYPT_MODE, bobDesKey);
            byte[] cleartext = "This is just an example".getBytes();
    //        Signature signature = Signature.getInstance("SHA1withDSA");
    //        signature.initSign(bobKpair.getPrivate());
    //        signature.update(cleartext);
    //        byte[] data = signature.sign();
            byte[] ciphertext = bobCipher.doFinal(cleartext);
            Cipher aliceCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
            aliceCipher.init(Cipher.DECRYPT_MODE, aliceDesKey);
            byte[] recovered = aliceCipher.doFinal(ciphertext);
            if (!java.util.Arrays.equals(cleartext, recovered))
                throw new Exception("DES in CBC mode recovered text is " +
                  "different from cleartext");
            System.out.println("DES in ECB mode recovered text is " +
                "same as cleartext");
            bobCipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
            bobCipher.init(Cipher.ENCRYPT_MODE, bobDesKey);
            cleartext = "This is just an example".getBytes();
            ciphertext = bobCipher.doFinal(cleartext);
            byte[] encodedParams = bobCipher.getParameters().getEncoded();
            AlgorithmParameters params = AlgorithmParameters.getInstance("DES");
            params.init(encodedParams);
            aliceCipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
            aliceCipher.init(Cipher.DECRYPT_MODE, aliceDesKey, params);
            recovered = aliceCipher.doFinal(ciphertext);
            if (!java.util.Arrays.equals(cleartext, recovered))
                throw new Exception("DES in CBC mode recovered text is " +
                  "different from cleartext");
            System.out.println("DES in CBC mode recovered text is " +
                "same as cleartext");
    }I want to sign the data with Signature,So i add the following code to the sample.
            byte[] cleartext = "This is just an example".getBytes();
         Signature signature = Signature.getInstance("SHA1withDSA");
            signature.initSign(bobKpair.getPrivate());
            signature.update(cleartext);
            byte[] data = signature.sign();
            byte[] ciphertext = bobCipher.doFinal(cleartext);Run the code again, the output is
    Error: java.security.InvalidKeyException: No installed provider supports this key: com.sun.crypto.provider.DHPrivateKey
    What's wrong with the code, It seems that the bob's private key is not instance of DSAPrivateKey but DHPrivateKey.
    what's your comment? thanks a lot.

    slamdunkming wrote:
    thank sabre150 for your reply. But the key pair is generated when I use DH to exchange the secret key. Yes! It is a DH key pair and cannot be used for signing. The DH key pair can only be used for secret sharing.
    If I can not use this private key to sign the data, what can i do?Do I have to generate another key pair for signature? In that way, I will have two key pair. Yep. You can generate a DSA or an RSA key pair to be used for signing.
    Because I use http protocol to exchange the key to get the shared secret key, Yep.
    If I generate another key pair, how can i send the public key to server? Since public keys are 'public' then you can send them in the open to anyone you like. In fact, if you don't publish your public keys then they are pretty much a waste of time. The biggest problem one has with public key is proving 'ownership' - if someone sends me a public key how do I know that the sender is actually who they say they are?.
    I am confused.Some reading might help. A pretty good starting point is "Beginning Cryptography with Java" by David Hook published by Wrox.

  • How to sign a document with certificate on USB key

    Hi everyone,
    I would like to know how to sign a document with a certificate on an USB key.
    Does anyone has already solve this problem ?
    Regards,
    Fred

    Hi Amitk,
    PDF is a commercial software which is not supported in MSDN forum. Maybe some forum talk about PDF is a better place to ask this question.
    I make a quick research on the web, and you may need to use some third party to sign a PDF document through DSC. Check this :
    http://stackoverflow.com/questions/378247/digitally-sign-pdf-files
    Hope this helps some.
    Shu
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to Intergrate the UWL with Entrust/PKI.

    Does anyone know how to integrate the UWL with Entrust certificate?  If you have any documentation, that would be great.
    Thanks
    Jean Seguin

    Hi,
    Do u want to integrate UWL with what back-end system? SAP Business Workflow, GP, MDM, etc?
    This is important cause the integration between EP and back-ends is made by System configuration in SLD.
    You can customize the UWL:
    http://help.sap.com/javadocs/NW04S/current/uw/UWL%20Custom%20Connector%20API.pdf
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e03bbd8c-0462-2910-f7ad-8c9c247f8dfd
    Reward points if it's helpful.

  • My Mac Pro tower quad core crashed and is showing a NO sign (the circle with a slash through it). How do I safely get it to come back up ? Model A1186

    My Mac Pro tower quad core crashed and is showing a NO sign (the circle with a slash through it). How do I safely get it to come back up ? Model A1186

    General purpose Mac troubleshooting guide:
    Isolating issues in Mac OS X
    Creating a temporary user to isolate user-specific problems:
    Isolating an issue by using another user account
    Identifying resource hogs and other tips:
    Using Activity Monitor to read System Memory and determine how much RAM is being used
    Starting the computer in "safe mode":
    Mac OS X: What is Safe Boot, Safe Mode?
    To identify potential hardware problems:
    Apple Hardware Test
    General Mac maintenance:
    Tips to keep your Mac in top form
    Troubleshooting: My computer won't turn on
    https://support.apple.com/kb/TS1367
    Where are your bootable backups and clones stored?
    What do you have to boot from to restore or attempt to recovery files that are not backed up?
    It won't be a PowerMac. People tend to think they look alike? or mean the same thing.
    http://www.everymac.com/systems/apple/mac_pro/specs/mac-pro-quad-2.66-specs.html
    Try zap PRAM and SMC Reset. If you have ATI 5770 which many have upgraded to you won't be able to use older DVD or systems than 10.6.5

  • How to sign java applet policy to end user?

    i have putted my applet class on server, i want all end users can access it on server, how to sign the java.policy to there JRE?
    can anyone help me?

    I found this some where else. It shows how to sign an applet.
    START OF DOC
    How To Sign a Java Applet
    The purpose of this document is to document the steps required to sign and use an
    applet using a self-signed cert or CA authorized in the JDK 1.3 plugin.
    The original 9 steps of this process were posted by user irene67 on suns message forum:
    http://forums.java.sun.com/thread.jsp?forum=63&thread=132769
    -----begin irene67's original message -----
    These steps describe the creation of a self-signed applet. This is useful for testing purposes. For use of public reachable applets, there will be needed a "real" certificate issued by an authority like VeriSign or Thawte. (See step 10 - no user will import and trust a self-signed applet from an unkown developer).
    The applet needs to run in the plugin, as only the plugin is platform- and browser-independent. And without this indepence, it makes no sense to use java...
    1. Create your code for the applet as usual.
    It is not necessary to set any permissions or use security managers in
    the code.
    2. Install JDK 1.3
    Path for use of the following commands: [jdk 1.3 path]\bin\
    (commands are keytool, jar, jarsigner)
    Password for the keystore is any password. Only Sun knows why...
    perhaps ;-)
    3. Generate key: keytool -genkey -keyalg rsa -alias tstkey
    Enter keystore password: *******
    What is your first and last name?
    [Unknown]: Your Name
    What is the name of your organizational unit?
    [Unknown]: YourUnit
    What is the name of your organization?
    [Unknown]: YourOrg
    What is the name of your City or Locality?
    [Unknown]: YourCity
    What is the name of your State or Province?
    [Unknown]: YS
    What is the two-letter country code for this unit?
    [Unknown]: US
    Is CN=Your Name, OU=YourUnit, O=YourOrg, L=YourCity, ST=YS, C=US
    correct?
    [no]: yes
    (wait...)
    Enter key password for tstkey
    (RETURN if same as keystore password):
    (press [enter])
    4. Export key: keytool -export -alias tstkey -file tstcert.crt
    Enter keystore password: *******
    Certificate stored in file tstcert.crt
    5. Create JAR: jar cvf tst.jar tst.class
    Add all classes used in your project by typing the classnames in the
    same line.
    added manifest
    adding: tst.class(in = 849) (out= 536)(deflated 36%)
    6. Verify JAR: jar tvf tst.jar
    Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/
    68 Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/MANIFEST.MF
    849 Thu Jul 27 12:49:04 GMT+02:00 2000 tst.class
    7. Sign JAR: jarsigner tst.jar tstkey
    Enter Passphrase for keystore: *******
    8. Verifiy Signing: jarsigner -verify -verbose -certs tst.jar
    130 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/MANIFEST.MF
    183 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/TSTKEY.SF
    920 Thu Jul 27 13:04:12 GMT+02:00 2000 META-INF/TSTKEY.RSA
    Thu Jul 27 12:58:28 GMT+02:00 2000 META-INF/
    smk 849 Thu Jul 27 12:49:04 GMT+02:00 2000 tst.class
    X.509, CN=Your Name, OU=YourUnit, O=YourOrg, L=YourCity, ST=YS, C=US
    (tstkey)
    s = signature was verified
    m = entry is listed in manifest
    k = at least one certificate was found in keystore
    i = at least one certificate was found in identity scope
    jar verified.
    9. Create HTML-File for use of the Applet by the Sun Plugin 1.3
    (recommended to use HTML Converter Version 1.3)
    10. (Omitted See Below)
    -----end irene67's original message -----
    To make the plug-in work for any browser you have two options with the JDK 1.3 plugin.
    1) Is to export a cert request using the key tool and send it to a CA verification source like verisign.
    When the reponse comes back, import it into the keystore overwriting the original cert for the generated key.
    To export request:
    keytool -certreg -alias tstkey -file tstcert.req
    To import response:
    keytool -import -trustcacerts -alias tstkey -file careply.crt
    An applet signed with a cert that has been verified by a CA source will automatically be recognized by the plugin.
    2) For development or otherwise, you may want to just use your self-signed certificate.
    In that case, the JDK 1.3 plugin will recognize all certs that have a root cert located in the JDK 1.3 cacerts keystore.
    This means you can import your test certificate into this keystore and have the plugin recognize your jars when you sign them.
    To import self-signed certificate into the cacerts keystore, change directory to where the JDK plugin key store is located.
    For JDK 1.3.0_02: C:\Program Files\JavaSoft\JRE\1.3.0_02\lib\security
    For JDK 1.3.1: C:\Program Files\JavaSoft\JRE\1.3.1\lib\security
    Import your self-signed cert into the cacerts keystore:
    keytool -import -keystore cacerts -storepass changeit -file tstcert.crt
    (the password is literally 'changeit')
    Now, regardless of which method you use, the applet should be recognized as coming from a signed jar. The user can choose to activate it if he / she chooses. If your applet uses classes from multiple jars, for example Apache's Xerce's parser, you will need to sign those jars as well to allow them to execute in the client's brower. Otherwise, only the classes coming from the signed jar will work with the java.security.AllPermission setting and all other classes from unsigned jars will run in the sandbox.
    NOTE: Unless otherwise specified by the -keystore command in all keytool and jarsigner operations, the keystore file used is named '.keystore' in the user's home directory.
    The first time any keystore is accessed (including the default) it will be created and secured with the first password given by the user. There is no way to figure out the password if you forget it, but you can delete the default file and recreate it if necessary. For most operations, using the -keystore command is safer to keep from cluttering or messing up your default keystore.

  • How to run an applet with JDBC connectivity on a web browser

    I've created an Applet in Java with SQL connectivity...i.e. it retrieves certain data from a table in SQL and puts in the TextField.....
    Now, the problem is that this Applet works in NETBEANS....but fails to work when I use a web-browser..or the "appletviewer" command....
    It says that it doesn't have permission to access local files....On Research, i've found that it is somethin' related to the concept of "Signed Applets", "Permissions" & "Security Policies" in java which doesn't allow any applet (without Certificate) to access Local Files.....
    Can Somebody please tell how to overcome this problem.....?

    I'm going to be blunt with you. You are most likely going to have to redesign your application from scratch. And if it turns out you don't have to then you should anyway because it's a bad idea and fraught with peril.
    Anyway here the major touchpoints on this discussion. You can be the judge of how these various points apply to you.
    - Applets are restricted. - Yes Applets have a number of security restrictions on what they can or cannot do. This is designed to protect users from malicious applets. By signing your applet you can request permission from the user to do certain activities that are otherwise restricted. But not all.
    - If you are using the JDBC-ODBC bridge then you need a different driver. If you sign your applet it might work in some limited scenarios but it will be hairy and is discouraged.
    - If you are using Access or another file based database (CSV Excel etc) then you are doomed. You'll have to get yourself a different database. A non file based one. It doesn't matter if you sign your applet or not. You're still doomed.
    - If you are trying to connect to a database server that is not at the same physical address as your web server you are doomed. Signing the applet will not help
    - Connecting directly to a database from an applet is extremely risky business. Starting with now anyone can steal your username and password for your database quite easily.
    What you should do in the redesign is put all the database accessing code in a Servlet. This Servlet does not have to be Java, it could be PHP, Perl, ASP, etc. It doesn't matter. Just put it on the server side. Then have your applet connect to this code via a webservice to do what is required.

  • How to load an applet with older version of JRE?

    Hi All,
    I'm writing an applet which should read the username from the user's system using System.getProperty("user.name") method. I've JRE 1.4.2 in my browser, and it's throwing a AccessControlException whenever the applet is trying to read the "user.name" system property. So, I want to load this particular applet with an older version of JRE, say JRE 1.3. I've tried various approaches like,
    <jsp:plugin type="applet" code="LoginApplet.class" archive="login.jar"
         jreversion="1.3"     iepluginurl="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
    </jsp:plugin>
    and also tried OBJECT tag,
    <OBJECT
    classid="clsid:CAFEEFAC-0013-0000-0000-ABCDEFFEDCBA" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"
         width="200" height="200" align="baseline" >
    <PARAM NAME="code" VALUE="LoginApplet.class">
    <PARAM NAME="archive" VALUE="login.jar">
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
    <PARAM NAME="scriptable" VALUE="true">
    No Java 2 SDK, Standard Edition v 1.3 support for APPLET!!
    </OBJECT>
    I've not tried the simple APPLET tag because we can't specify a java plugin using the APPLET tag.
    In both the above methods, I'm still getting AccessControlException. In Java console, I'm seeing Java Plugin as 1.4.2.
    Can someone tell me is it possible to read the "user.name" system property from user's machine using Applets? If yes, how?
    Thanks,
    Tarun.

    Applets are prevented from doing certain things - reading data is one - to maximize security. You can either add permissions to the computer that the applet is running on, or you can sign the applet.
    See
    http://java.sun.com/docs/books/tutorial/security1.2/tour1/step2.html
    and
    http://forum.java.sun.com/thread.jspa?threadID=686184&tstart=45

  • I don't understand how to sign an applet

    Hi
    could you indicate me how to sign an applet or documentation which deals with this subject...
    Thanx

    I assume that by now your applet is signed and that it can be loaded into the browser and that the Java-plug-in will do something with your applet.
    Look into the Java console after your applet has stopped running. (There is a coffee mug at the lower right corner of the screen).
    For debugging an applet this Java console is quite practical.
    If issued from within an applet, statements like
    System.out.println("Some info for debugging\n");
    will print into the Java console. You can also use that in a catch-part of a try-catch-finally construct:
    try {
        // some method which may raise an exception
    catch( Exception e ) {
        System.out.println(" * ooops * " + e.getMessage() + "\n");
    }

  • How to start java applet with netbeans 6.1

    hey,
    I want to learn how to start java applet (with database) with netbeans.. I'm new to java...can you show me how can i start..if you have any doc about it can you send it to me..thank you..:)

    You really should be asking this NetBeans question at the NB site - these forums are for Java language topics, not NB support.
    [http://www.netbeans.org/kb/61/web/applets.html]
    Almost any NB question you have can be answered by either the NB web documentation or the NB program's Help.

  • How to sign iPhone application using developer certificates

    Hello,
    will anyone tell me that how to sign the iPhone application using developer certificate and one more thing that how will i get the developer certificate.
    Thanks

    ya i got the solution, just go through the following link...
    you will also know how we do that..
    http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphonedevelopment/120-Running_Applications/runningapplications.html
    http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphonedevelopment/128-Managing_Devices/devices.html#//appleref/doc/uid/TP40007959-CH4-SW38

  • Does Anybody know how to keep the license files and Certificates in ISE-3315 During the upgrade.

    Hi,
    I have two ISE-3315 Appliances in production network.
    I need someone's help to explain, how to make the Secondary node as the primary admin note to reset-config.
    And then I would like to know how to keep the license files and Certificate during the Upgrade.
    Please help me to answer my questions.
    Thanks
    CSCO11872447

    The Cisco Identity Services Engine (ISE) provides distributed  deployment of runtime services with centralized configuration and  management. Multiple nodes can be deployed together in a distributed  fashion to support failover.
    If you register a  secondary Monitoring ISE node, it is recommended that you first back up  the primary Monitoring ISE node and then restore the data to the new  secondary Monitoring ISE node. This ensures that the history of the  primary Monitoring ISE node is in sync with the new secondary node as  new changes are replicated.
    Please  Check the below configuration guide for Secondary ISE- Nodes.
    http://www.cisco.com/en/US/docs/security/ise/1.0/user_guide/ise10_dis_deploy.pdf

  • How to kill the applet

    how to kill the applet which in the browser.
    With Regards
    Santhosh

    my code.. this is main program for my applet. can find out errors. if not i will send the code to u.
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.net.*;
    import java.io.*;
    public class StyleEditor extends Applet implements ItemListener ,ColorListener
        public ImageButton imgBold,imgItalic;
        public ColorButton colorButton;
        public Choice fontFace,fontSize;
        public TextArea textArea;
        public Panel toolBar,textPanel;
        public String content;
        public Font font = new Font("Arial",Font.ITALIC,16);
        public ColorDialog dialog;
        public Frame f;
        public String sColor;
        public InputStream in;
        private int size[] = {8,10,12,14,18,24,36};
        private Label textLabel;
        public void init()
            try
                setLayout(new BorderLayout());
                toolBar = new Panel();
                toolBar.setBackground(Color.lightGray);
                Toolkit toolkit = getToolkit();
                in = StyleEditor.class.getResourceAsStream("bold.gif");
                byte bin[] = new byte[in.available()];
                in.read(bin);
                Image ibold = toolkit.createImage(bin);
                in = StyleEditor.class.getResourceAsStream("italic.gif");
                byte binc[] = new byte[in.available()];
                in.read(binc);
                Image iitalic = toolkit.createImage(binc);
                imgBold = new ImageButton(ibold);
                imgItalic = new ImageButton(iitalic);
                fontFace = new Choice();
                fontSize = new Choice();
                colorButton = new ColorButton();
                f = new Frame();
                dialog = new ColorDialog(f,"Color Chooser",true,StyleEditor.this);
                textLabel = new Label("             Edit Style   ",Label.CENTER);
                textLabel.setFont(new Font("Arial",Font.BOLD,18));
                String editColor= getParameter("editcolor");
                if(editColor!=null)
                    int eValue = Integer.parseInt(editColor,16);
                    textLabel.setForeground(new Color(eValue));
                String fontArray[] = toolkit.getFontList();
                content = getParameter("style");
                String fname = getParameter("fname");
                String fsize = getParameter("fsize");
                Boolean bBold = new Boolean(getParameter("bold"));
                Boolean bItalic = new Boolean(getParameter("italic"));
                sColor= getParameter("oldcolor").substring(1);
                int value = Integer.parseInt(sColor,16);
                colorButton.setColor(new Color(value));
                boolean bold = bBold.booleanValue();
                boolean italic = bItalic.booleanValue();
                imgBold.setSelected(bold);
                imgItalic.setSelected(italic);
                for(int i=0;i<fontArray.length;i++)
                    fontFace.addItem(fontArray);
    fontFace.addItemListener(this);
    for(int i=0;i<size.length;i++)
    fontSize.addItem(size[i]+"");
    fontSize.addItemListener(this);
    toolBar.setLayout(new FlowLayout(FlowLayout.LEFT));
    toolBar.add(imgBold);
    toolBar.add(imgItalic);
    toolBar.add(fontFace);
    toolBar.add(fontSize);
    toolBar.add(colorButton);
    toolBar.add(textLabel);
    textPanel = new Panel();
    textPanel.setLayout(new BorderLayout());
    textArea = new TextArea(content);
    textArea.setEditable(false);
    textArea.setBackground(Color.white);
    textArea.setForeground(new Color(value));
    if(fname!=null && fsize!=null)
    setStyleFont(fname,fsize,bold,italic);
    textPanel.add(textArea);
    add(toolBar,BorderLayout.NORTH);
    add(textPanel,BorderLayout.CENTER);
    imgBold.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    boldActionPerformed(ae);
    imgItalic.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    italicActionPerformed(ae);
    colorButton.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    if(!dialog.isVisible())
    dialog = null;
    dialog = new ColorDialog(f,"Color Chooser",true,StyleEditor.this);
    dialog.setLocation(colorButton.getLocation());
    dialog.setLocation(200,200);
    dialog.pack();
    dialog.setVisible(true);
    }catch(Exception e)
    System.out.println(e);
    public void setStyleFont(String fname,String fsize,boolean bold,boolean italic)
    int s = sizeValue(Integer.parseInt(fsize));
    fontFace.select(fname);
    fontSize.select(s+"");
    if(bold && italic)
    font = new Font(fname,Font.BOLD+Font.ITALIC,s);
    textArea.setFont(font);
    return;
    }else
    if(bold)
    font = new Font(fname,Font.BOLD,s);
    textArea.setFont(font);
    return;
    }else
    if(italic)
    font = new Font(fname,Font.ITALIC,s);
    textArea.setFont(font);
    return;
    }else
    font = new Font(fname,Font.PLAIN,s);
    textArea.setFont(font);
    return;
    public void itemStateChanged(ItemEvent e)
    String f = fontFace.getSelectedItem();
    String s = fontSize.getSelectedItem();
    font = new Font(f,font.getStyle(),Integer.parseInt(s));
    textArea.setFont(font);
    public void boldActionPerformed(ActionEvent ae)
    if(imgBold.isSelected())
    if(imgItalic.isSelected())
    font = new Font(font.getName(),Font.BOLD+Font.ITALIC,font.getSize());
    textArea.setFont(font);
    return;
    font = new Font(font.getName(),Font.BOLD,font.getSize());
    textArea.setFont(font);
    return;
    }else
    if(imgItalic.isSelected())
    font = new Font(font.getName(),Font.ITALIC,font.getSize());
    textArea.setFont(font);
    return;
    font = new Font(font.getName(),Font.PLAIN,font.getSize());
    textArea.setFont(font);
    return;
    public void italicActionPerformed(ActionEvent ae)
    if(imgItalic.isSelected())
    if(imgBold.isSelected())
    font = new Font(font.getName(),Font.BOLD+Font.ITALIC,font.getSize());
    textArea.setFont(font);
    return;
    font = new Font(font.getName(),Font.ITALIC,font.getSize());
    textArea.setFont(font);
    return;
    }else
    if(imgBold.isSelected())
    font = new Font(font.getName(),Font.BOLD,font.getSize());
    textArea.setFont(font);
    return;
    font = new Font(font.getName(),Font.PLAIN,font.getSize());
    textArea.setFont(font);
    return;
    public boolean isBold()
    return imgBold.isSelected();
    public boolean isItalic()
    return imgItalic.isSelected();
    public void colorSelection(Color currentColor)
    colorButton.setColor(currentColor);
    textArea.setForeground(currentColor);
    int r = currentColor.getRed();
    String red = Integer.toHexString(r);
    if(red.length()==1)
    red = 0+red;
    int g = currentColor.getGreen();
    String green =Integer.toHexString(g);
    if(green.length()==1)
    green = 0+green;
    int b = currentColor.getBlue();
    String blue =Integer.toHexString(b);
    if(blue.length()==1)
    blue = 0+blue;
    sColor = red+green+blue;
    public String getName()
    return font.getName();
    public int getFSize()
    switch(font.getSize())
    case 8 : return 1;
    case 10 : return 2;
    case 12 : return 3;
    case 14 : return 4;
    case 18 : return 5;
    case 24 : return 6;
    case 36 : return 7;
    default : return 0;
    public int sizeValue(int value)
    switch(value)
    case 1 : return 8;
    case 2 : return 10;
    case 3 : return 12;
    case 4 : return 14;
    case 5 : return 18;
    case 6 : return 24;
    case 7 : return 36;
    default : return 0;
    public void stop()
    System.out.println("Stop");
    destroy();
    public void destroy()
    imgBold=null;
    imgItalic=null;
    colorButton = null;
    fontFace =null;
    fontSize=null;
    textArea=null;
    toolBar=null;
    textPanel=null;
    content=null;
    font = null;
    dialog=null;
    f=null;
    sColor=null;
    in=null;
    textLabel=null;
    super.destroy();

  • How to sign into imessage with a different apple ID

    How to sign into imessage with a different apple ID

    Why are you posting the same question in a separate thread. You have already been provided an answer.
    GB

  • How to delete the file with space in name

    Hi
    I want to delete the file "test ex.txt" file.
    i run the following command in command prompt.i can delete the file successfully.
    /bin/rm -f /mnt/"test ex.txt"
    I want to run the command from java.So i am using the following code
    String cmd = "/bin/rm -f /mnt/\"test ex.txt\"";
         Runtime rt = Runtime.getRuntime();
    process = rt.exec(cmd);
    The file was not deleted.
    How to delete the file with space in name?
    Help me

    Use the form of exec that takes an array of command + args.
    arr[0] = "/bin/rm"
    arr[1] = "-f"
    arr[2] = "/home/me/some directory with spaces";Or use ProcessBuilder, which is the preferred replacement for Runtime.exec, and which Runtime.exec calls.

Maybe you are looking for