2022년 1월 27일 목요일

Java Web Start 이용해서 excel 실행

참고사이트 https://www.baeldung.com/java-web-start https://github.com/eugenp/tutorials/tree/master/jws https://docs.oracle.com/javase/7/docs/technotes/guides/javaws/developersguide/development.html#security * 이클립스에서 dynamic web app 프로젝트 생성 * Hello 클래스 구현 -------------------------------------------------------------------------------- package com.example; import javax.swing.JFrame; import javax.swing.JLabel; public class Hello { public static void main(String[] args) throws Exception { JFrame f = new JFrame("main"); f.setSize(200, 100); f.setLocationRelativeTo(null); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("Hello, world!"); f.add(label); f.setVisible(true); //FilePermission p = new FilePermission("<>", "execute"); Runtime.getRuntime().exec("cmd /c start excel.exe"); } } -------------------------------------------------------------------------------- * Configure > Add maven nature * pom.xml -------------------------------------------------------------------------------- '>http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 webapp webapp 0.0.1-SNAPSHOT war src maven-compiler-plugin 3.7.0 1.8 1.8 maven-war-plugin 3.0.0 WebContent org.apache.maven.plugins maven-jar-plugin compile jar com.example.Hello ${project.basedir}/WebContent -------------------------------------------------------------------------------- * servlet 관련 jar 파일 복사 아래 URL에서 jardiff.jar, jnlp-servlet.jar 파일을 받아 WEB-INF/lib에 복사 https://github.com/eugenp/tutorials/tree/master/jws/java-core-samples-lib * WEB-INF/web.xml 편집 -------------------------------------------------------------------------------- Java Web Start JNLP Example for Java Web Start Article JnlpDownloadServlet jnlp.sample.servlet.JnlpDownloadServlet JnlpDownloadServlet *.jar JnlpDownloadServlet *.jnlp index.html -------------------------------------------------------------------------------- * WebContent 디렉토리에 index.html 파일생성 -------------------------------------------------------------------------------- Launch -------------------------------------------------------------------------------- * WebContent 디렉토리에 hello.jnlp 파일생성 -------------------------------------------------------------------------------- Hello Example -------------------------------------------------------------------------------- * jar 파일생성: 프로젝트 우클릭 > Run As > Maven Install * jar 파일 sign cmd > cd [webapp-dir] # keytool -genkey -keystore myKeystore -alias myself # keytool -selfcert -alias myself -keystore myKeystore # keytool -list -keystore myKeystore # jarsigner -keystore myKeystore webapp-0.0.1-SNAPSHOT.jar myself * 톰켓에 Dynamic web app 프로젝트를 추가하고 시작 * http://localhost:8080/webapp/ 접속 & Launch 버튼클릭 hello.jnlp 다운로드 hello.jnpl 파일열기

댓글 없음:

댓글 쓰기