i have button view image attached log entry , when user clicks button want open image in user's default image viewer on windows machine?
how know viewer in default image viewer?
right i'm doing doesn't work:
string filename = "\""+(string)attachmentscombobox.getselecteditem()+"\""; runtime.getruntime().exec("rundll32.exe c:\\windows\\system32\\shimgvw.dll,imageview_fullscreen "+filename); and doesn't work mean doesn't anything. tried run command in command line , nothing happened. no error, nothing.
try cmd /c start
public class test2 { public static void main(string[] args) throws exception { string filename = "c:\\temp\\test.bmp"; string [] commands = { "cmd.exe" , "/c", "start" , "\"dummytitle\"", "\"" + filename + "\"" }; process p = runtime.getruntime().exec(commands); p.waitfor(); system.out.println("done."); } } this start default photo viewer associated file extension.
a better way use java.awt.desktop.
import java.awt.desktop; import java.io.file; public class test2 { public static void main(string[] args) throws exception { file f = new file("c:\\temp\\test.bmp"); desktop dt = desktop.getdesktop(); dt.open(f); system.out.println("done."); } }
Comments
Post a Comment