Page 1 of 2 12 LastLast
Results 1 to 20 of 22
  1. #1
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default Java application won't run in windows but will on mac osx?

    I'm not really understanding why this is a problem, My java application compiled and is completely done, but for reasons I don't understand it will not launch in windows now.

    I have compiled everything into a .jar file, but for reasons unknown the jar file will run on my macbook but it will not run on my pc at the moment. I have ruled out different Java versions as both my mac and pc have the same java version.

    Prior to adding a while loop type of thing into my main function there was no issue.

    To my code all I added was this to my main function

    Java Code:
     while ((nextLine = reader.readNext()) != null) { 
           if(nextLine.length==30){
                //if(nextLine[blah]!=null){  // if there are comments 
                jLabel11.setForeground(Color.red); //turn jlabel red
                jLabel11.setText(nextLine[blah]);  // show the instructions
                System.out.println("if blah isn't null");
           // }
           }
            
                if(nextLine.length<30){
               System.out.println("it's going into null"); 
                jLabel11.setForeground(Color.green);
            jLabel11.setText("No Instructions");
            System.out.println("made it to second if");
            }
            
            
         }
    After this windows refuses to get past the filechooser. Is there something going on here that I'm not aware of?




    whole code
    Java Code:
    package evansinterface;
    import static evansinterface.BoxItems.*;
    import java.awt.Color;
    import java.io.BufferedWriter;
    import java.io.FileNotFoundException;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.DefaultComboBoxModel;
    import javax.swing.JFileChooser;
    import javax.swing.filechooser.FileNameExtensionFilter;
    import java.io.File;
    import com.opencsv.CSVReader;
    import java.io.FileReader;
    import java.util.List;
    
    
    
    
    
    /**
     *
     * @author 
     */ 
     
    public final class mainWindow extends javax.swing.JFrame {
        private Object br;
        
           int blah = 29; 
            
    
        mainWindow() throws FileNotFoundException, IOException  {
          //  int line =1;
            initComponents();
            templateFile = openFile();
            
            
            if(templateFile == null){ // if template file has nothing in it
              System.exit(0);  // quit application
            }
            File file = fileSelect.getSelectedFile();  //
            CSVReader reader = new CSVReader(new FileReader(file));
            String [] nextLine;
         // int returnVal = chooser.showOpenDialog(parent);
       // if(fileSelect.APPROVE_OPTION == 1) {
        //   System.out.println("You chose to open this file: " +fileSelect.getSelectedFile().getName());
        
        
            while ((nextLine = reader.readNext()) != null) { 
           if(nextLine.length==30){
                //if(nextLine[blah]!=null){  // if there are comments 
                jLabel11.setForeground(Color.red); //turn jlabel red
                jLabel11.setText(nextLine[blah]);  // show the instructions
                System.out.println("if blah isn't null");
           // }
           }
            
                if(nextLine.length<30){
               System.out.println("it's going into null"); 
                jLabel11.setForeground(Color.green);
            jLabel11.setText("No Instructions");
            System.out.println("made it to second if");
            }
            
            
         }
        
            
            
            
            progress = 1;
            changedAn = false;
            fileReader = new CsvFileReader(templateFile);
            allData = fileReader.getLines();
            getDataRange();
            
            jProgressBar1.setMaximum(dataRange);
            jProgressBar1.setValue(progress);
            jProgressBar1.setString(progress + "/" + dataRange);
            jComboBox3.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(TANTALUM)));
            jComboBox4.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(ANODE)));
            jComboBox5.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(ANODE)));
            jComboBox6.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(ANODE)));
            jComboBox7.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(ANODE)));
            jComboBox8.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(ANODE)));
            jComboBox9.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(CATHODE)));
            jComboBox1.setModel(new DefaultComboBoxModel(fileReader.getBoxItems(GLASSING)));
        }
         
        private void getDataRange(){
            int q = 0;
            while(allData[1][q] != null){q++;}
            dataRange = q;
        }
          
          
          
    
    
        
        /**
         * This method is called from within the constructor to initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is always
         * regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")
        
        
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
    
            jFrame1 = new javax.swing.JFrame();
            jDialog1 = new javax.swing.JDialog();
            jMenuItem1 = new javax.swing.JMenuItem();
            buttonGroup1 = new javax.swing.ButtonGroup();
            fileSelect = new javax.swing.JFileChooser();
            jTextField2 = new javax.swing.JTextField();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel4 = new javax.swing.JLabel();
            jComboBox3 = new javax.swing.JComboBox();
            jLabel5 = new javax.swing.JLabel();
            jComboBox4 = new javax.swing.JComboBox();
            jLabel6 = new javax.swing.JLabel();
            jComboBox5 = new javax.swing.JComboBox();
            jLabel7 = new javax.swing.JLabel();
            jComboBox6 = new javax.swing.JComboBox();
            jLabel8 = new javax.swing.JLabel();
            jComboBox7 = new javax.swing.JComboBox();
            jLabel9 = new javax.swing.JLabel();
            jComboBox8 = new javax.swing.JComboBox();
            jLabel10 = new javax.swing.JLabel();
            jComboBox9 = new javax.swing.JComboBox();
            jProgressBar1 = new javax.swing.JProgressBar();
            nextButton = new javax.swing.JButton();
            jTextField4 = new javax.swing.JTextField();
            backButton = new javax.swing.JButton();
            jLabel3 = new javax.swing.JLabel();
            jComboBox1 = new javax.swing.JComboBox();
            jLabel11 = new javax.swing.JLabel();
    
            javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
            jFrame1.getContentPane().setLayout(jFrame1Layout);
            jFrame1Layout.setHorizontalGroup(
                jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 400, Short.MAX_VALUE)
            );
            jFrame1Layout.setVerticalGroup(
                jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 300, Short.MAX_VALUE)
            );
    
            javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
            jDialog1.getContentPane().setLayout(jDialog1Layout);
            jDialog1Layout.setHorizontalGroup(
                jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 400, Short.MAX_VALUE)
            );
            jDialog1Layout.setVerticalGroup(
                jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 300, Short.MAX_VALUE)
            );
    
            jMenuItem1.setText("jMenuItem1");
    
            fileSelect.setCurrentDirectory(new java.io.File("/Z:\\\\Database Current\\Assembly Lots\\"));
                fileSelect.setDialogTitle("Select CSV Template File");
                fileSelect.setFileFilter(new FileNameExtensionFilter("CSV FILES", "csv", "commaSeperatedValue"));
    
                setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    
                jTextField2.setText("1");
                jTextField2.setToolTipText("Serial Number");
                jTextField2.setMaximumSize(new java.awt.Dimension(102, 2147483647));
                jTextField2.setName(""); // NOI18N
                jTextField2.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jTextField2ActionPerformed(evt);
                    }
                });
    
                jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
                jLabel1.setText("Current Item");
                jLabel1.setToolTipText("");
    
                jLabel2.setText("Header Glassing");
    
                jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
                jLabel4.setText("Tantalum Lot");
    
                jComboBox3.setMaximumRowCount(20);
                jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
                jComboBox3.setMaximumSize(new java.awt.Dimension(102, 32767));
                jComboBox3.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jComboBox3ActionPerformed(evt);
                    }
                });
    
                jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
                jLabel5.setText("Anode Lot 1");
    
                jComboBox4.setMaximumRowCount(20);
                jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
                jComboBox4.setMaximumSize(new java.awt.Dimension(102, 32767));
                jComboBox4.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jComboBox4ActionPerformed(evt);
                    }
                });
    
                jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
                jLabel6.setText("Anode Lot 2");
    
                jComboBox5.setMaximumRowCount(20);
                jComboBox5.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
                jComboBox5.setMaximumSize(new java.awt.Dimension(102, 32767));
                jComboBox5.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jComboBox5ActionPerformed(evt);
                    }
                });
    
                jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
                jLabel7.setText("Anode Lot 3");
    
                jComboBox6.setMaximumRowCount(20);
                jComboBox6.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
                jComboBox6.setMaximumSize(new java.awt.Dimension(102, 32767));
                jComboBox6.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jComboBox6ActionPerformed(evt);
                    }
                });
    
                jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
                jLabel8.setText("Anode Lot 4");
    
                jComboBox7.setMaximumRowCount(20);
                jComboBox7.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
                jComboBox7.setMaximumSize(new java.awt.Dimension(102, 32767));
                jComboBox7.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jComboBox7ActionPerformed(evt);
                    }
                });
    
                jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
                jLabel9.setText("Anode Lot 5");
    
                jComboBox8.setMaximumRowCount(20);
                jComboBox8.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
                jComboBox8.setMaximumSize(new java.awt.Dimension(102, 32767));
                jComboBox8.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jComboBox8ActionPerformed(evt);
                    }
                });
    
                jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
                jLabel10.setText("Cathode Lot");
    
                jComboBox9.setMaximumRowCount(20);
                jComboBox9.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
                jComboBox9.setMaximumSize(new java.awt.Dimension(102, 32767));
                jComboBox9.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jComboBox9ActionPerformed(evt);
                    }
                });
    
                jProgressBar1.setMaximum(40);
                jProgressBar1.setMinimum(1);
                jProgressBar1.setToolTipText("Progress");
                jProgressBar1.setString("1/40");
                jProgressBar1.setStringPainted(true);
    
                nextButton.setText("Next");
                nextButton.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        nextButtonActionPerformed(evt);
                    }
                });
    
                jTextField4.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jTextField4ActionPerformed(evt);
                    }
                });
    
                backButton.setText("Back");
                backButton.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        backButtonActionPerformed(evt);
                    }
                });
    
                jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
                jLabel3.setText("Notes");
    
                jComboBox1.setMaximumRowCount(20);
                jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1" }));
                jComboBox1.setMaximumSize(new java.awt.Dimension(102, 32767));
                jComboBox1.setMinimumSize(new java.awt.Dimension(102, 27));
                jComboBox1.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jComboBox1ActionPerformed(evt);
                    }
                });
    
                jLabel11.setText("jLabel11");
    
                javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
                getContentPane().setLayout(layout);
                layout.setHorizontalGroup(
                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField4)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(backButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(nextButton))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jComboBox4, 0, 102, Short.MAX_VALUE)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jComboBox5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jComboBox6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(18, 18, 18)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                        .addGap(18, 18, 18)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jComboBox7, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(18, 18, 18)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jComboBox8, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(18, 18, 18)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jComboBox9, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(142, 142, 142)
                        .addComponent(jLabel11)
                        .addGap(0, 0, Short.MAX_VALUE))
                );
                layout.setVerticalGroup(
                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBox6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBox7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBox8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBox9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nextButton)
                            .addComponent(backButton)
                            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel11)
                        .addContainerGap())
                );
    
                jProgressBar1.getAccessibleContext().setAccessibleName("");
    
                pack();
            }// </editor-fold>                        
    
        private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {                                            
     
        }                                           
    
        private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) {                                           
          
        }                                          
    
        private void jComboBox4ActionPerformed(java.awt.event.ActionEvent evt) {                                           
            changedAn = true;
        }                                          
    
        private void jComboBox7ActionPerformed(java.awt.event.ActionEvent evt) {                                           
            changedAn = true;
        }                                          
    
        private void jComboBox5ActionPerformed(java.awt.event.ActionEvent evt) {                                           
            changedAn = true;
        }                                          
    
        private void jComboBox8ActionPerformed(java.awt.event.ActionEvent evt) {                                           
            changedAn = true;
        }                                          
    
        private void jComboBox6ActionPerformed(java.awt.event.ActionEvent evt) {                                           
            changedAn = true;
        }                                          
    
        private void jComboBox9ActionPerformed(java.awt.event.ActionEvent evt) {                                           
         
        }                                          
    
        private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
            writeDatas();
            
            if(progress > dataRange){
                writeOutFile();
                System.exit(0);
            }
        }                                          
    
        private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {                                            
            // TODO add your handling code here:
        }                                           
       
        private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
            if(progress > 1){
            progress--;
            jTextField2.setText(String.valueOf(progress));
            jProgressBar1.setValue(progress);
            jProgressBar1.setString(progress + "/" + dataRange);
            }
        }                                          
    
        private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
            // TODO add your handling code here:
        }                                          
    
        /**
         * @param args the command line arguments
         */
        
        public static void main(String args[]) {
    
            /* Create and display the form */
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    try {
                        new mainWindow().setVisible(true);
                    } catch (FileNotFoundException ex) {
                        Logger.getLogger(mainWindow.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (IOException ex) {
                        Logger.getLogger(mainWindow.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            });
        }
        
        private File openFile(){
            int returnVal = fileSelect.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fileSelect.getSelectedFile();
            try {
                return file;
            } catch (Exception ex) {
              System.out.println("problem accessing file"+file.getAbsolutePath());
              return null;
            }
        } else {
            System.out.println("File access cancelled by user.");
            return null;
        }
        }
        
        
        private String checkNA(String inString){
            if(inString.equals("-----"))
                return "";
            else return inString;
        }
        
        
        private boolean isNum(String str){
            try{
                double d = Double.parseDouble(str);
            }
            catch(NumberFormatException nfe){
                return false;
            }
            return true;
            
        }
        
        private String compileOutput(){
            String oneOut = "";
            oneOut += ",,,,,,,,";
            oneOut += checkNA(jComboBox4.getSelectedItem().toString());
            oneOut += ",";
            oneOut += checkNA(jComboBox5.getSelectedItem().toString());
            oneOut += ",";
            oneOut += checkNA(jComboBox6.getSelectedItem().toString());
            oneOut += ",";
            oneOut += checkNA(jComboBox7.getSelectedItem().toString());
            oneOut += ",";
            oneOut += checkNA(jComboBox8.getSelectedItem().toString());
            oneOut += ",";
            oneOut += checkNA(jComboBox9.getSelectedItem().toString());
            oneOut += ",,";
            oneOut += checkNA(jComboBox3.getSelectedItem().toString());
            oneOut += ",,";
            oneOut += checkNA(jComboBox1.getSelectedItem().toString());
            oneOut += ",,,,,,,,,,";
            return oneOut;
        }
        
        private void anCheck(){
            if(changedAn){
                if(jComboBox8.getSelectedIndex() > 0){
                    jComboBox7.setSelectedIndex(jComboBox8.getSelectedIndex());
                }
                if(jComboBox7.getSelectedIndex() > 0){
                    jComboBox6.setSelectedIndex(jComboBox7.getSelectedIndex());
                }
                if(jComboBox6.getSelectedIndex() > 0){
                    jComboBox5.setSelectedIndex(jComboBox6.getSelectedIndex());
                }
                if(jComboBox5.getSelectedIndex() > 0){
                    jComboBox4.setSelectedIndex(jComboBox5.getSelectedIndex());
                }
                changedAn = false;
            }
        }
        
        private void writeOutFile(){
            try {
                FileWriter fileOut = new FileWriter(templateFile, false);
                fileOut.write("");
                fileOut = new FileWriter(templateFile, true);
                BufferedWriter writeOut = new BufferedWriter(fileOut);
                
                for (String allData1 : allData[0]) {
                    writeOut.append(allData1 + "\n");
                }
                
                for(int i = 0; i < dataRange; i++){
                    writeOut.append(allData[1][i]);
                }
                
                for (String allData1 : allData[2]) {
                    if(allData1 != null)
                        writeOut.append(allData1 + "\n");
                }
                
                writeOut.close();
                
            } catch (IOException ex) {
                System.out.println("File not written.");
            }
        }
        
        private void writeDatas(){
            if(progress <= dataRange){
            while(progress < Integer.parseInt(jTextField2.getText())){
                if(progress < dataRange){
                    dataText = allData[1][progress - 1];
                    dataText = dataText.substring(0, dataText.indexOf(','));
    
                    allData[1][progress - 1] = dataText + ",," + progress + newOut + ",\n";
    
                    progress++;
                }
            }
            
            dataText = allData[1][progress - 1];
            dataText = dataText.substring(0, dataText.indexOf(','));
            
            newOut = compileOutput();
            
            allData[1][progress - 1] = dataText + ",," + progress + newOut + jTextField4.getText() + ",\n";
            
            jTextField4.setText("");
            
            anCheck();
            
            progress++;
            jTextField2.setText(String.valueOf(progress));
            jProgressBar1.setValue(progress);
            jProgressBar1.setString(progress + "/" + dataRange);
            
            if(progress >= dataRange - 1){
                nextButton.setText("Finish");
            }
            }
         
    }
        
        
        
    
        // Variables declaration - do not modify                     
        private javax.swing.JButton backButton;
        private javax.swing.ButtonGroup buttonGroup1;
        private javax.swing.JFileChooser fileSelect;
        private javax.swing.JComboBox jComboBox1;
        private javax.swing.JComboBox jComboBox3;
        private javax.swing.JComboBox jComboBox4;
        private javax.swing.JComboBox jComboBox5;
        private javax.swing.JComboBox jComboBox6;
        private javax.swing.JComboBox jComboBox7;
        private javax.swing.JComboBox jComboBox8;
        private javax.swing.JComboBox jComboBox9;
        private javax.swing.JDialog jDialog1;
        private javax.swing.JFrame jFrame1;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel10;
        private javax.swing.JLabel jLabel11;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JLabel jLabel6;
        private javax.swing.JLabel jLabel7;
        private javax.swing.JLabel jLabel8;
        private javax.swing.JLabel jLabel9;
        private javax.swing.JMenuItem jMenuItem1;
        private javax.swing.JProgressBar jProgressBar1;
        private javax.swing.JTextField jTextField2;
        private javax.swing.JTextField jTextField4;
        private javax.swing.JButton nextButton;
        // End of variables declaration                   
    
    private String dataText;
    private String stuff;
    private File templateFile;
    private String noteText;
    private String duplicateText;
    private int progress;
    private String[][] allData;
    private String[] topData;
    private String[] enteredData;
    private int dataRange;
    String newOut;
    private final CsvFileReader fileReader;
    boolean changedAn;
    
    
        
    }
    Last edited by innovo; 09-11-2015 at 06:09 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Java application won't run in windows but will on mac osx?

    will not run on my pc
    Please explain what "not run" means.

    What error message do you get that could explain what happens?

    To see any error messages from the java program:
    Open a command prompt window
    change directory to the one with the jar file
    enter the command: java -jar THEJARFILENAME.jar

    Copy the full contents of the command prompt window and paste it here
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default Re: Java application won't run in windows but will on mac osx?

    Quote Originally Posted by Norm View Post
    Please explain what "not run" means.

    What error message do you get that could explain what happens?

    To see any error messages from the java program:
    Open a command prompt window
    change directory to the one with the jar file
    enter the command: java -jar THEJARFILENAME.jar

    Copy the full contents of the command prompt window and paste it here
    by "not run" I mean opening, getting to the filechooser, and then immediately closing afterward with no error message. also do I need to tell it the directory?
    Last edited by innovo; 09-11-2015 at 05:19 PM.

  4. #4
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    211
    Rep Power
    0

    Default Re: Java application won't run in windows but will on mac osx?

    Where is your filechooser at? I don't see it in the while loop.
    Stephen

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Java application won't run in windows but will on mac osx?

    Ok, I think of run and execute as the same thing.
    Is the problem that Your code executes but does not do what you want?

    getting to the filechooser, and then immediately closing
    You need to post the code that shows the problem.

    How are you debugging the program? Do you have lots of println() statements to show how the execution flow is going and how the values of variables are changed?
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default Re: Java application won't run in windows but will on mac osx?

    Quote Originally Posted by Norm View Post
    Ok, I think of run and execute as the same thing.
    Is the problem that Your code executes but does not do what you want?


    You need to post the code that shows the problem.



    How are you debugging the program? Do you have lots of println() statements to show how the execution flow is going and how the values of variables are changed?
    It turns out it seems to hate my external library for some odd reason. In the cmd terminal it says that line 43 is a problem. line 43 is where I start using the opencsv library.
    So something about the external library it hates for unclear reasons.

    my whole code is listed above


    it also seems to not recognize the external library import com.opencsv.CSVReader;
    Last edited by innovo; 09-11-2015 at 06:16 PM.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Java application won't run in windows but will on mac osx?

    In the cmd terminal it says that line 43 is a problem
    Please copy the full text of the error message and paste it here. It has important info about the error.

    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my response, don't ignore it, ask a question.

  8. #8
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    211
    Rep Power
    0

    Default Re: Java application won't run in windows but will on mac osx?

    Hello,

    In addition to Norm's reply, it seems your not using an IDE, e.g. netbeans. Is that true?

    An IDE like Netbeans would notify you if there was any issues with imports and etc.

    Stephen

  9. #9
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default Re: Java application won't run in windows but will on mac osx?

    Quote Originally Posted by shall View Post
    Hello,

    In addition to Norm's reply, it seems your not using an IDE, e.g. netbeans. Is that true?

    An IDE like Netbeans would notify you if there was any issues with imports and etc.

    Stephen
    I am using netbeans, it compiled perfectly fine here but on windows it has a problem with the external library

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Java application won't run in windows but will on mac osx?

    I thought that you were trying to execute the contents of a jar file on a Windows PC, that jar file was successfully executed on a mac-osx. There was no IDE present. Just a jar file that worked on mac and failed on Windows.

    Please explain all the details about the problem you are having.
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default Re: Java application won't run in windows but will on mac osx?

    Quote Originally Posted by Norm View Post
    Please copy the full text of the error message and paste it here. It has important info about the error.

    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    full error message

    C:\Users\TEvans>java -jar C:\Users\TEvans\Desktop\EvansInterface.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: com/opencsv/CSVReader
    at evansinterface.mainWindow.<init>(mainWindow.java:4 9)
    at evansinterface.EvansInterface.main(EvansInterface. java:29)
    Caused by: java.lang.ClassNotFoundException: com.opencsv.CSVReader
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 2 more

  12. #12
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default Re: Java application won't run in windows but will on mac osx?

    Quote Originally Posted by Norm View Post
    I thought that you were trying to execute the contents of a jar file on a Windows PC, that jar file was successfully executed on a mac-osx. There was no IDE present. Just a jar file that worked on mac and failed on Windows.

    Please explain all the details about the problem you are having.
    oh I misunderstood what he meant. I thought he was saying that I didn't code this in an IDE. yes I am trying to run the .jar file without an IDE

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Java application won't run in windows but will on mac osx?

    I'm confused now. You said:
    but for reasons unknown the jar file will run on my macbook but it will not run on my pc
    And now you say you are executing the program from inside of netbeans.
    I am using netbeans
    Surely netbeans would give you some error messages that would help you solve the problem.
    If you don't understand my response, don't ignore it, ask a question.

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Java application won't run in windows but will on mac osx?

    I am trying to run the .jar file without an IDE
    If the program needs class files from another jar file, the Class-Path: field in the jar file needs to point to the other jar file.

    How did the jar file work on the mac if it did not have that entry in the jar file?
    If you don't understand my response, don't ignore it, ask a question.

  15. #15
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default Re: Java application won't run in windows but will on mac osx?

    Quote Originally Posted by Norm View Post
    I'm confused now. You said:

    And now you say you are executing the program from inside of netbeans.


    Surely netbeans would give you some error messages that would help you solve the problem.
    I coded the .jar application in netbeans on my macbook, then I put that .jar file onto a pc to run. That is what's going on right now.

    When I was coding in netbeans it had no problem compiling and packaging the file and gave me no error message.

    However when I run the .jar application on windows --the terminal seems to say that windows can't find opencsv

    at the same time, that exact same .jar file works on mac osx. meaning mac osx for unclear reasons can see opencsv while windows can't
    Last edited by innovo; 09-11-2015 at 06:58 PM.

  16. #16
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default Re: Java application won't run in windows but will on mac osx?

    Quote Originally Posted by Norm View Post
    If the program needs class files from another jar file, the Class-Path: field in the jar file needs to point to the other jar file.

    How did the jar file work on the mac if it did not have that entry in the jar file?
    because I imported opencsv's library into netbeans

  17. #17
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Java application won't run in windows but will on mac osx?

    that exact same .jar file works on mac osx. meaning mac osx for unclear reasons can see opencsv while windows can't
    On the mac, what is the name of the jar file with the opencsv classes and where is it located?

    On windows, what is the name of the jar file with the opencsv classes and where is it located?
    If you don't understand my response, don't ignore it, ask a question.

  18. #18
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default Re: Java application won't run in windows but will on mac osx?

    Quote Originally Posted by Norm View Post
    On the mac, what is the name of the jar file with the opencsv classes and where is it located?

    On windows, what is the name of the jar file with the opencsv classes and where is it located?
    on mac osx it's in my netbeans projects folder

    EvansInterface/dist/lib/opencsv-3.4.jar

    on windows I didn't put it there because I thought the compiling and packaging would include the opencsv in it

  19. #19
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Java application won't run in windows but will on mac osx?

    Does the jar file have a Class-Path: line? Open the jar file in a zip file utility and look at the manifest file.
    One way to do that would be to rename the .jar file by adding .zip and then opening it.

    The jar file needs to be available on windows and the manifest file's Class-Path: line needs to point to it.
    If you don't understand my response, don't ignore it, ask a question.

  20. #20
    innovo is offline Member
    Join Date
    Jul 2015
    Posts
    84
    Rep Power
    0

    Default Re: Java application won't run in windows but will on mac osx?

    Quote Originally Posted by Norm View Post
    Does the jar file have a Class-Path: line? Open the jar file in a zip file utility and look at the manifest file.
    One way to do that would be to rename the .jar file by adding .zip and then opening it.

    The jar file needs to be available on windows and the manifest file's Class-Path: line needs to point to it.
    the manifest is a .mf file, how would I go about opening that and adding the line I need? changing it to .txt and using notepad?

    alternatively can I make a properties file to direct to the right place?

Page 1 of 2 12 LastLast

Similar Threads

  1. Java application installer for windows
    By nando88 in forum Java Applets
    Replies: 3
    Last Post: 11-09-2013, 04:52 AM
  2. java application as windows service
    By gerard kowara in forum JDBC
    Replies: 1
    Last Post: 11-05-2010, 09:08 AM
  3. Replies: 0
    Last Post: 04-12-2009, 04:16 PM
  4. Replies: 4
    Last Post: 09-14-2008, 05:19 AM
  5. JAVA application residing on the windows tool bar!
    By rameshraj in forum Advanced Java
    Replies: 19
    Last Post: 04-30-2008, 03:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •