Results 1 to 5 of 5
  1. #1
    patriotsfan is offline Member
    Join Date
    May 2011
    Posts
    38
    Rep Power
    0

    Default Read Text Files/Picstures from a jar

    I have an executable jar which is a JApplet and I need to read many text files and one picture file. The program operates the way I want inside netbeans "run" mode. I signed the JApplet and I also made sure all .txt files and .gif file is included inside the executable jar. I did this by changing .jar to .zip extension and making sure all files that it needs to operate were included. Any suggestions to fix my problem?

    I have read some discussions on other websites but I have not been able to get them to work. Some of my previous resources were...

    Java Tips - Read a text file from a jar
    How to read a text file from JAR - Nokia Developer Wiki

    But I don't really understand how to use them properly, if they are even what I need to solve my problem.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: Read Text Files/Picstures from a jar

    Please post the code you are having problems with.
    If your program classes are in the same jar file as the files to be read, the best way to read "files" from a jar file is to treat them as resources and use the Class class's getResource methods.

  3. #3
    patriotsfan is offline Member
    Join Date
    May 2011
    Posts
    38
    Rep Power
    0

    Default Re: Read Text Files/Picstures from a jar

    I will post the code from my main class. I created from netbeans gui bulder, so a lot of extra code. How would I use them as resources? Would I just add a method or replace how I include the files in my program?

    Java Code:
    package regAid;
    
    import java.awt.Toolkit;
    import java.io.*;
    import javax.swing.JFrame;
    
    public class GUI extends javax.swing.JApplet 
    {       
        private SearchForm tempSearchForm;
        private AboutForm tempAboutForm;
        public static boolean addToList = false;
        public String[] searchSyllabusInfo;
        boolean CSS1 = false;
        boolean BUS1 = false;
        boolean ENG1 = false;
        String cssClassNames = "src/regAid/CSS_ClassNames.txt";
        String cssSyllabusInfo = "src/regAid/CSS_SyllabusInfo.txt";
        String busClassNames = "src/regAid/BUS_ClassNames.txt";
        String busSyllabusInfo = "src/regAid/BUS_SyllabusInfo.txt";
        String engClassNames = "src/regAid/ENG_ClassNames.txt";
        String engSyllabusInfo = "src/regAid/ENG_SyllabusInfo.txt";
        MajorArrayList CSS = new MajorArrayList(cssClassNames, cssSyllabusInfo);
        MajorArrayList BUS = new MajorArrayList(busClassNames, busSyllabusInfo);
        MajorArrayList ENG = new MajorArrayList(engClassNames, engSyllabusInfo);
        buildList b1 = new buildList(CSS);
        buildList b2 = new buildList(BUS);
        buildList b3 = new buildList(ENG);
        int currentSizeOfMajors;
    
        public static void main(String[] args) throws IOException 
        {
            //... Create an initialize the applet.
            GUI theApplet = new GUI();
    
            theApplet.init();         // Needed if overridden in applet
    
            //theApplet.start();        // Needed if overridden in applet
    
            //... Create a window (JFrame) and make applet the content pane.
            JFrame window = new JFrame("Registration Aid");
            window.setContentPane(theApplet);
    
            window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            window.pack();              // Arrange the components.
            window.setVisible(true);    // Make the window visible.
            window.setIconImage(Toolkit.getDefaultToolkit().getImage("src/RegAid/UW_Icon.gif"));
            window.setLocationRelativeTo(null);
            theApplet.engineeringJButton.setVisible(false); //Disables Engineering Button
            theApplet.engineeringJMenuItem.setVisible(false); //Disables Engineering Menu Item
        }
        /** Initializes the applet second */
        @Override
        public void init() 
        {        
            setSize(800, 400);
            //      majorsJList.setVisible(false);
            /* Set the Nimbus look and feel */
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
            * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
            */
            try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
            javax.swing.UIManager.setLookAndFeel(info.getClassName());
            break;
            }
            }
            } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
            //</editor-fold>
    
            /* Create and display the applet */
            try 
            {
                java.awt.EventQueue.invokeAndWait(new Runnable() 
                {
                    public void run() 
                    {
                        initComponents();
                    }
                });
            } 
            catch (Exception ex) 
            {
                ex.printStackTrace();
            }        
        }
    
        /** This method is called from within the init() method 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() {
    
            jPopupMenu1 = new javax.swing.JPopupMenu();
            jScrollPane1 = new javax.swing.JScrollPane();
            majorsJList = new javax.swing.JList();
            jScrollPane2 = new javax.swing.JScrollPane();
            syllabusJTextArea = new javax.swing.JTextArea();
            engineeringJButton = new javax.swing.JButton();
            cssJButton = new javax.swing.JButton();
            businessJButton = new javax.swing.JButton();
            searchJButton = new javax.swing.JButton();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            jMenuBar1 = new javax.swing.JMenuBar();
            fileJMenu = new javax.swing.JMenu();
            searchMenuItem = new javax.swing.JMenuItem();
            jSeparator1 = new javax.swing.JPopupMenu.Separator();
            exitJMenuItem = new javax.swing.JMenuItem();
            viewJMenu = new javax.swing.JMenu();
            businessJMenuItem = new javax.swing.JMenuItem();
            cssJMenuItem = new javax.swing.JMenuItem();
            engineeringJMenuItem = new javax.swing.JMenuItem();
            navigateJMenu = new javax.swing.JMenu();
            firstJMenuItem = new javax.swing.JMenuItem();
            previousJMenuItem = new javax.swing.JMenuItem();
            nextJMenuItem = new javax.swing.JMenuItem();
            lastJMenuItem = new javax.swing.JMenuItem();
            helpJMenu = new javax.swing.JMenu();
            aboutJMenuItem = new javax.swing.JMenuItem();
    
            setBackground(new java.awt.Color(204, 204, 204));
            setName("mainJApplet"); // NOI18N
            addFocusListener(new java.awt.event.FocusAdapter() {
                public void focusGained(java.awt.event.FocusEvent evt) {
                    formFocusGained(evt);
                }
            });
    
            majorsJList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
                public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                    majorsJListValueChanged(evt);
                }
            });
            jScrollPane1.setViewportView(majorsJList);
    
            syllabusJTextArea.setColumns(20);
            syllabusJTextArea.setEditable(false);
            syllabusJTextArea.setRows(5);
            jScrollPane2.setViewportView(syllabusJTextArea);
    
            engineeringJButton.setText("Engineering");
            engineeringJButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    engineeringJButtonActionPerformed(evt);
                }
            });
    
            cssJButton.setText("CSS");
            cssJButton.setPreferredSize(new java.awt.Dimension(89, 23));
            cssJButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    cssJButtonActionPerformed(evt);
                }
            });
    
            businessJButton.setText("Business");
            businessJButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    businessJButtonActionPerformed(evt);
                }
            });
    
            searchJButton.setText("Search");
            searchJButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    searchJButtonActionPerformed(evt);
                }
            });
    
            jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
            jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel1.setText("Majors");
    
            jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12));
            jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel2.setText("Syllabus Information");
            jLabel2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    
            jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12));
            jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel3.setText("Classes");
    
            fileJMenu.setText("File");
    
            searchMenuItem.setText("Search");
            searchMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    searchMenuItemActionPerformed(evt);
                }
            });
            fileJMenu.add(searchMenuItem);
            fileJMenu.add(jSeparator1);
    
            exitJMenuItem.setText("Exit");
            exitJMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    exitJMenuItemActionPerformed(evt);
                }
            });
            fileJMenu.add(exitJMenuItem);
    
            jMenuBar1.add(fileJMenu);
    
            viewJMenu.setText("View");
    
            businessJMenuItem.setText("Business");
            businessJMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    businessJMenuItemActionPerformed(evt);
                }
            });
            viewJMenu.add(businessJMenuItem);
    
            cssJMenuItem.setText("CSS");
            cssJMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    cssJMenuItemActionPerformed(evt);
                }
            });
            viewJMenu.add(cssJMenuItem);
    
            engineeringJMenuItem.setText("Engineering");
            engineeringJMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    engineeringJMenuItemActionPerformed(evt);
                }
            });
            viewJMenu.add(engineeringJMenuItem);
    
            jMenuBar1.add(viewJMenu);
    
            navigateJMenu.setText("Navigate");
    
            firstJMenuItem.setText("First Major");
            firstJMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    firstJMenuItemActionPerformed(evt);
                }
            });
            navigateJMenu.add(firstJMenuItem);
    
            previousJMenuItem.setText("Previous Major");
            previousJMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    previousJMenuItemActionPerformed(evt);
                }
            });
            navigateJMenu.add(previousJMenuItem);
    
            nextJMenuItem.setText("Next Major");
            nextJMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    nextJMenuItemActionPerformed(evt);
                }
            });
            navigateJMenu.add(nextJMenuItem);
    
            lastJMenuItem.setText("Last Major");
            lastJMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    lastJMenuItemActionPerformed(evt);
                }
            });
            navigateJMenu.add(lastJMenuItem);
    
            jMenuBar1.add(navigateJMenu);
    
            helpJMenu.setText("Help");
    
            aboutJMenuItem.setText("About");
            aboutJMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    aboutJMenuItemActionPerformed(evt);
                }
            });
            helpJMenu.add(aboutJMenuItem);
    
            jMenuBar1.add(helpJMenu);
    
            setJMenuBar(jMenuBar1);
    
            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, false)
                        .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(searchJButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(engineeringJButton, javax.swing.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE)
                        .addComponent(cssJButton, javax.swing.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE)
                        .addComponent(businessJButton, javax.swing.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(7, 7, 7)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(6, 6, 6)
                            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 750, Short.MAX_VALUE))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(20, 20, 20)
                            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 740, Short.MAX_VALUE)))
                    .addContainerGap())
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(jLabel1)
                        .addComponent(jLabel3))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE))
                            .addContainerGap())
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(businessJButton, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(cssJButton, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(engineeringJButton, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 142, Short.MAX_VALUE)
                            .addComponent(searchJButton, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(27, 27, 27))))
            );
        }// </editor-fold>                        
    public String readFromJARFile(String filename)
    throws IOException
    {
      InputStream is = getClass().getResourceAsStream(filename);
      InputStreamReader isr = new InputStreamReader(is);
      BufferedReader br = new BufferedReader(isr);
      StringBuffer sb = new StringBuffer();
      String line;
      while ((line = br.readLine()) != null) 
      {
        sb.append(line);
      }
      br.close();
      isr.close();
      is.close();
      return sb.toString();
    }
    public void displaySearchResults(String[] majorsFound, String[] syllabusesFound, int sizeIn)
    {
        //Sets the Jlist with majors found
        currentSizeOfMajors = sizeIn;
        majorsJList.setListData(majorsFound);
        searchSyllabusInfo = syllabusesFound;
        
        BUS1 = false;
        CSS1 = false;
        ENG1 = false;
        addToList = true;
    }
    private void majorsJListValueChanged(javax.swing.event.ListSelectionEvent evt) {                                         
        int index = (majorsJList.getSelectedIndex());
        
        try
        {
            if (index <= -1 )
                throw new IndexOutOfBoundsException();
        }
        catch(IndexOutOfBoundsException e)
        {
            index = 0;
            majorsJList.setSelectedIndex(index);
        }
        
        if (BUS1 == true)
            syllabusJTextArea.setText(BUS.get(index).getDescription());
        if (CSS1 == true)
            syllabusJTextArea.setText(CSS.get(index).getDescription());
        if (ENG1 == true)
            syllabusJTextArea.setText(ENG.get(index).getDescription());
        if (addToList == true)
            syllabusJTextArea.setText(searchSyllabusInfo[index]);
    
        syllabusJTextArea.setCaretPosition(0);
    }                                        
    
    private void businessJButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                
       BUS1 = true;
       CSS1 = false;
       ENG1 = false;
       addToList = false;
       currentSizeOfMajors = BUS.getSize();
       majorsJList.setListData(BUS.getNameArray());
       majorsJList.setSelectedIndex(0);      
    }                                               
    
    private void cssJButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
       BUS1 = false;
       CSS1 = true;
       ENG1 = false;
       addToList = false;
       currentSizeOfMajors = CSS.getSize();
       majorsJList.setListData(CSS.getNameArray());
       majorsJList.setSelectedIndex(0);
    }                                          
    
    private void engineeringJButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                   
       BUS1 = false;
       CSS1 = false;
       ENG1 = true;
       addToList = false;
       currentSizeOfMajors = ENG.getSize();
       majorsJList.setListData(ENG.getNameArray());
       majorsJList.setSelectedIndex(0);
    }                                                  
    
    private void exitJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                              
        System.exit(0);
    }                                             
    
    private void searchJButtonActionPerformed(java.awt.event.ActionEvent evt) {                                              
        tempSearchForm = new SearchForm(null, true, this);
        tempSearchForm.setVisible(true);
    }                                             
    
    private void formFocusGained(java.awt.event.FocusEvent evt) {                                 
    
    }                                
    
    private void aboutJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                               
        tempAboutForm = new AboutForm(null, true);
        tempAboutForm.setVisible(true);
    }                                              
    
    private void searchMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                               
        searchJButtonActionPerformed(evt);
    }                                              
    
    private void businessJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                                  
        businessJButtonActionPerformed(evt);
    }                                                 
    
    private void cssJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                             
        cssJButtonActionPerformed(evt);
    }                                            
    
    private void engineeringJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                                     
        engineeringJButtonActionPerformed(evt);
    }                                                    
    
    private void firstJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                               
        majorsJList.setSelectedIndex(0);
        majorsJList.ensureIndexIsVisible(0);
    }                                              
    
    private void previousJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                                  
        int initialIndex = majorsJList.getSelectedIndex();
        if (currentSizeOfMajors != 0)
        {
            majorsJList.setSelectedIndex(initialIndex - 1);
            majorsJList.ensureIndexIsVisible(initialIndex - 1);
        }
    }                                                 
    
    private void nextJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                              
        int initialIndex = majorsJList.getSelectedIndex();
        majorsJList.setSelectedIndex(initialIndex + 1);
        majorsJList.ensureIndexIsVisible(initialIndex + 1);
    }                                             
    
    private void lastJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                              
        int lastIndex = (currentSizeOfMajors - 1);
        majorsJList.setSelectedIndex(lastIndex);
        majorsJList.ensureIndexIsVisible(lastIndex);
    }                                             
    
        // Variables declaration - do not modify                     
        private javax.swing.JMenuItem aboutJMenuItem;
        private javax.swing.JButton businessJButton;
        private javax.swing.JMenuItem businessJMenuItem;
        private javax.swing.JButton cssJButton;
        private javax.swing.JMenuItem cssJMenuItem;
        private javax.swing.JButton engineeringJButton;
        private javax.swing.JMenuItem engineeringJMenuItem;
        private javax.swing.JMenuItem exitJMenuItem;
        private javax.swing.JMenu fileJMenu;
        private javax.swing.JMenuItem firstJMenuItem;
        private javax.swing.JMenu helpJMenu;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JMenuBar jMenuBar1;
        private javax.swing.JPopupMenu jPopupMenu1;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JScrollPane jScrollPane2;
        private javax.swing.JPopupMenu.Separator jSeparator1;
        private javax.swing.JMenuItem lastJMenuItem;
        public javax.swing.JList majorsJList;
        private javax.swing.JMenu navigateJMenu;
        private javax.swing.JMenuItem nextJMenuItem;
        private javax.swing.JMenuItem previousJMenuItem;
        private javax.swing.JButton searchJButton;
        private javax.swing.JMenuItem searchMenuItem;
        private javax.swing.JTextArea syllabusJTextArea;
        private javax.swing.JMenu viewJMenu;
        // End of variables declaration                   
    }

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default Re: Read Text Files/Picstures from a jar

    Can you make a small test program what tries to do what you want to do?
    This is too much code to go through for working on the simple problem of reading a file from a jar file.

  5. #5
    patriotsfan is offline Member
    Join Date
    May 2011
    Posts
    38
    Rep Power
    0

    Default Re: Read Text Files/Picstures from a jar

    Got it to work. Used an inputstream instead of just a string. Took a bunch of trial and error.

Similar Threads

  1. Replies: 18
    Last Post: 05-02-2011, 05:37 PM
  2. Files, cannot read!
    By LennyKosmos in forum New To Java
    Replies: 2
    Last Post: 10-02-2010, 01:35 PM
  3. working with files (text files)
    By itaipee in forum New To Java
    Replies: 1
    Last Post: 02-24-2009, 11:38 AM
  4. Behaving text files like binary files
    By Farzaneh in forum New To Java
    Replies: 2
    Last Post: 08-27-2008, 03:20 PM
  5. Text and image files within jar files
    By erhart in forum Advanced Java
    Replies: 8
    Last Post: 01-19-2008, 04:43 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
  •