Java 无输出回馈

Java no output giving back

我从互联网的某个地方得到了这个脚本,它应该做的是将文本加密成 md5 并显示结果(我认为)我是 Java 的新手,只能做一点点 php 和 python。我设置 JDK 这样我就可以在 cmd 中 运行 它了。我输入的是 >javac MD5.java 然后它 运行s 代码和 C:\file> 再次出现,就好像什么都没发生一样。它没有向我打印哈希,有人知道为什么吗?

import java.io.FileInputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5 {
    public static String getMD5(String input) {
        byte[] source;
        try {
            //Get byte according by specified coding.
            source = input.getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            source = input.getBytes();
        }
        String result = null;
        char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7',
                '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(source);
            //The result should be one 128 integer
            byte temp[] = md.digest();
            char str[] = new char[16 * 2];
            int k = 0;
            for (int i = 0; i < 16; i++) {
                byte byte0 = temp[i];
                str[k++] = hexDigits[byte0 >>> 4 & 0xf];
                str[k++] = hexDigits[byte0 & 0xf];
            }
            result = new String(str);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    public static void main(String[] args) throws NoSuchAlgorithmException {
        System.out.println(getMD5("test"));
    }
}
javac MD5.java

编译代码。 运行 应用程序使用

java MD5