user73318: Here some java code. What i need to change to get compressed public address in getPublicAddress?
import com.google.bitcoin.core.Address;
import com.google.bitcoin.core.ECKey;
import com.google.bitcoin.params.MainNetParams;
import org.spongycastle.crypto.digests.RIPEMD160Digest;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class DigestUtil {

    public static byte[] RIPEMD160(byte[] input) {
        RIPEMD160Digest d = new RIPEMD160Digest();

        d.update(input, 0, input.length);

        byte[] o = new byte[d.getDigestSize()];

        d.doFinal(o, 0);

        return o;
    }

    public static byte[] SHA256(byte[] input) {
        byte[] hash = null;

        try {
            MessageDigest md = MessageDigest.getInstance("SHA-256");
            md.update(input);
            hash = md.digest();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }

        return hash;
    }

    public static ECKey createAddress(byte[] secret) {
        byte[] hash = SHA256(secret);

        ECKey key = new ECKey(hash, null);

        return key;
    }

    public static String getPublicAddress(String input) {
        ECKey address = createAddress(input.getBytes());

        byte[] hash160 = RIPEMD160(SHA256(address.getPubKey()));

        Address addr = new Address(MainNetParams.get(), hash160);

        return addr.toString();
    }

}


user73827: Address address = new Address(params, dk.decompress().getPubKeyHash());

where dk is the DeterministicKey
or 
key.decompress().getPubKey();

where key is the ECKey

user91228: In case some one want to implement compression in their code:
private static final String EVEN = "02";
private static final String ODD = "03";

public String compressPublicKey(String toCompress) {
    if (Integer.parseInt(toCompress.substring(128, 130), 16) % 2 == 0)
        return  EVEN + toCompress.substring(2, 66);
    return ODD + toCompress.substring(2, 66);
} 


73318: <p>Here some java code. What i need to change to get compressed public address in getPublicAddress?</p>

<pre><code>import com.google.bitcoin.core.Address;
import com.google.bitcoin.core.ECKey;
import com.google.bitcoin.params.MainNetParams;
import org.spongycastle.crypto.digests.RIPEMD160Digest;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class DigestUtil {

    public static byte[] RIPEMD160(byte[] input) {
        RIPEMD160Digest d = new RIPEMD160Digest();

        d.update(input, 0, input.length);

        byte[] o = new byte[d.getDigestSize()];

        d.doFinal(o, 0);

        return o;
    }

    public static byte[] SHA256(byte[] input) {
        byte[] hash = null;

        try {
            MessageDigest md = MessageDigest.getInstance("SHA-256");
            md.update(input);
            hash = md.digest();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }

        return hash;
    }

    public static ECKey createAddress(byte[] secret) {
        byte[] hash = SHA256(secret);

        ECKey key = new ECKey(hash, null);

        return key;
    }

    public static String getPublicAddress(String input) {
        ECKey address = createAddress(input.getBytes());

        byte[] hash160 = RIPEMD160(SHA256(address.getPubKey()));

        Address addr = new Address(MainNetParams.get(), hash160);

        return addr.toString();
    }

}
</code></pre>
 73827: <pre><code>Address address = new Address(params, dk.decompress().getPubKeyHash());
</code></pre>

<p>where dk is the DeterministicKey</p>

<p>or </p>

<pre><code>key.decompress().getPubKey();
</code></pre>

<p>where key is the ECKey</p>
 91228: <p>In case some one want to implement compression in their code:</p>
<pre><code>private static final String EVEN = &quot;02&quot;;
private static final String ODD = &quot;03&quot;;

public String compressPublicKey(String toCompress) {
    if (Integer.parseInt(toCompress.substring(128, 130), 16) % 2 == 0)
        return  EVEN + toCompress.substring(2, 66);
    return ODD + toCompress.substring(2, 66);
} 
</code></pre>
