I have no idea if I can just run this code and it will work but here:
public void actionPerformed(ActionEvent e) {
try
{
Runtime rt = Runtime.getRuntime();
Process p = rt.exec("c:\\Users\\Toby\\AppData\\Roaming\\.minecraft\\minecraft.exe");
}
catch(Exception a)
{
}
}
This is linked to a button, and it launches the minecraft launcher. If I want to give it to my friends, what do I have to do so that it doesn't look for the user 'Toby', but instead looks for their home folder? Sorry if its confusing!
I think you're looking for the user.home property. There's a list of properties available here: http://www.mindspring.com/~mgrand/java-system-properties.htm
So, your code would be changed to:
Process p = rt.exec(System.getProperty("user.home") + \\AppData\\Roaming\\.minecraft\\minecraft.exe");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With