从java打开EDrawingViewer文件
我有一个用鼠标在pc上运行的应用程序,我想用java中的特定文件名启动EdrawingViewer,然后当用户返回到全屏应用程序时,如果他们没有关闭它,我想关闭它。这是我到目前为止的一个快速演示,但我不知道为了启动具有特定文件的solidworks,应该在参数中添加什么从java打开EDrawingViewer文件,java,windows,cmd,solidworks,Java,Windows,Cmd,Solidworks,我有一个用鼠标在pc上运行的应用程序,我想用java中的特定文件名启动EdrawingViewer,然后当用户返回到全屏应用程序时,如果他们没有关闭它,我想关闭它。这是我到目前为止的一个快速演示,但我不知道为了启动具有特定文件的solidworks,应该在参数中添加什么 package com.protocase.hmiclient.edrawings; import java.awt.event.ActionEvent; import java.awt.event.ActionListene
package com.protocase.hmiclient.edrawings;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JFrame;
/**
* @author DavidH
*/
public class EDrawingHelper {
public static File[] getEDrawingsForJob(final String jobNumber) {
File f = new File("\\\\itsugar\\www\\HMI\\POD EDRAWINGS");
File[] matchingFiles = f.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.startsWith(jobNumber) && (name.endsWith("EASM") || name.endsWith("EDRW"));
}
});
return matchingFiles;
}
public static void test(String[] args) {
File[] files = getEDrawingsForJob("G080111004-13162-1");
for (File file : files){
System.out.println(file.getName());
}
}
public static void openEDrawingForFileName(String fileName){
try {
final Process process = Runtime.getRuntime().exec("C:\\Program Files\\SolidWorks Corp\\SolidWorks eDrawings (2)\\EModelViewer.exe \\\\itsugar\\www\\HMI\\POD EDRAWINGS\\"+fileName);
JFrame frame = new JFrame();
JButton killButton = new JButton("KILL");
killButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
process.destroy();
System.exit(0);
}
});
frame.getContentPane().add(killButton);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
openEDrawingForFileName("G080111004-13162-1 ASSEMBLY.EASM");
}
}
我不认为这是solidworks的问题,我认为这只是我传递错误或格式错误之类的问题。似乎通过FileProtocolHandler运行它会导致它正常打开
final Process process = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler \\\\itsugar\\www\\HMI\\POD EDRAWINGS\\"+fileName);