|
Por : scaamanho - Thu 10 Apr 2008 No Comments - | |
Normalemente para abri un documento de M$ Word desde una aplicación Java, usamos una solución nativa dependiente del sistema operativo.
-
Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL \""+fileName+"\"");
o bien
-
Runtime.getRuntime().exec("cmd /c \""+fileName+"\"");
Existen alternativas más elegantes e idependientes del sistema operativo, mediante la librería JDIC (https://jdic.dev.java.net/) y su clase org.jdesktop.jdic.desktop.Desktop.
O si usamos una vesion de la JavaSE 6, podemos hacer uso de la clase Desktop
-
try
-
{
-
Desktop.getDesktop().open( new
File("c:/word.doc") ); -
}
-
catch (
Exception /* IOException, URISyntaxException */ e ) -
{
-
e.printStackTrace();
-
}

