Bir vb komut dosyası oluşturarak bunu ve java bunu yürütebilirsiniz:
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class Shourtcut {
public static void main(String[] args) {
String path = System.getProperty("user.dir") + System.getProperty("file.separator") + "shourtcut.jar";
path = '"' + path + '"';
try {
File file = File.createTempFile("shortcut_geni", ".vbs");
file.deleteOnExit();
try (FileWriter fw = new java.io.FileWriter(file)) {
String vbs = "Set oWS = WScript.CreateObject(\"WScript.Shell\") \n"
+ "sLinkFile = oWS.ExpandEnvironmentStrings(\"%HOMEDRIVE%%HOMEPATH%\\Desktop\\jar_file_name.lnk\")\n"
+ "Set oLink = oWS.CreateShortcut(sLinkFile)\n "
+ "oLink.TargetPath = oWS.ExpandEnvironmentStrings(" + path + ")\n"
+ "oLink.Save \n";
fw.write(vbs);
}
Process p = Runtime.getRuntime().exec("wscript " + file.getPath());
p.waitFor();
} catch (IOException | InterruptedException e) {
System.out.println("" + e);
}
}
}
http://stackoverflow.com/questions/343776/how-do-you-create-and-read-windows -shortcut-lnk-file-in-java yardımcı olabilir –
Adım 1: Bunu http://stackoverflow.com/a/10226697/1897935 yapın. Adım 2: dosya var mı kontrol edin, başka oluşturun. –
[http://stackoverflow.com/questions/1496343/how-to-create-shortcut-icon-for-java-program](http://stackoverflow.com/questions/1496343/how-to-create-shortcut -icon-for-java-program) – stark9000