/restart/restart/starter.java

http://myseriesproject.googlecode.com/ · Java · 130 lines · 87 code · 18 blank · 25 comment · 0 complexity · fd1a9f25c707477ab6c263c6b4ed9ec0 MD5 · raw file

  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. /*
  6. * starter.java
  7. *
  8. * Created on 27 Απρ 2011, 1:03:14 μμ
  9. */
  10. package restart;
  11. import java.io.BufferedReader;
  12. import java.io.File;
  13. import java.io.IOException;
  14. import java.io.InputStreamReader;
  15. import java.util.logging.Level;
  16. import java.util.logging.Logger;
  17. /**
  18. *
  19. * @author ssoldatos
  20. */
  21. public class starter extends javax.swing.JFrame {
  22. /** Creates new form starter */
  23. public starter() {
  24. initComponents();
  25. setLocationRelativeTo(null);
  26. setVisible(true);
  27. validate();
  28. repaint();
  29. }
  30. /** This method is called from within the constructor to
  31. * initialize the form.
  32. * WARNING: Do NOT modify this code. The content of this method is
  33. * always regenerated by the Form Editor.
  34. */
  35. @SuppressWarnings("unchecked")
  36. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  37. private void initComponents() {
  38. jPanel1 = new javax.swing.JPanel();
  39. jLabel1 = new javax.swing.JLabel();
  40. jProgressBar1 = new javax.swing.JProgressBar();
  41. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  42. setResizable(false);
  43. setUndecorated(true);
  44. jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
  45. jLabel1.setFont(jLabel1.getFont().deriveFont(jLabel1.getFont().getStyle() | java.awt.Font.BOLD, jLabel1.getFont().getSize()+2));
  46. jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
  47. jLabel1.setText("Restarting MySeries");
  48. jProgressBar1.setIndeterminate(true);
  49. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  50. jPanel1.setLayout(jPanel1Layout);
  51. jPanel1Layout.setHorizontalGroup(
  52. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  53. .addGroup(jPanel1Layout.createSequentialGroup()
  54. .addContainerGap()
  55. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  56. .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)
  57. .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE))
  58. .addContainerGap())
  59. );
  60. jPanel1Layout.setVerticalGroup(
  61. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  62. .addGroup(jPanel1Layout.createSequentialGroup()
  63. .addContainerGap()
  64. .addComponent(jLabel1)
  65. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  66. .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  67. .addContainerGap(19, Short.MAX_VALUE))
  68. );
  69. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  70. getContentPane().setLayout(layout);
  71. layout.setHorizontalGroup(
  72. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  73. .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  74. );
  75. layout.setVerticalGroup(
  76. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  77. .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  78. );
  79. pack();
  80. }// </editor-fold>//GEN-END:initComponents
  81. /**
  82. * @param args the command line arguments
  83. */
  84. public static void main(String args[]) {
  85. java.awt.EventQueue.invokeLater(new Runnable() {
  86. public void run() {
  87. new starter();
  88. }
  89. });
  90. try {
  91. Thread.sleep(2000);
  92. } catch (InterruptedException ex) {
  93. Logger.getLogger(starter.class.getName()).log(Level.SEVERE, null, ex);
  94. }
  95. go();
  96. }
  97. // Variables declaration - do not modify//GEN-BEGIN:variables
  98. private javax.swing.JLabel jLabel1;
  99. private javax.swing.JPanel jPanel1;
  100. private javax.swing.JProgressBar jProgressBar1;
  101. // End of variables declaration//GEN-END:variables
  102. private static void go() {
  103. String pathToApp = new File("myseriesproject.jar").getAbsolutePath();
  104. File startingDir = new File("myseriesproject.jar").getAbsoluteFile().getParentFile();
  105. String[] envp = null; // should inherit the environment
  106. try {
  107. Process p = Runtime.getRuntime().exec(new String[]{"java", "-jar", pathToApp}, envp, startingDir);
  108. System.exit(0);
  109. } catch (IOException ex) {
  110. }
  111. }
  112. }