Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7830147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:05:42+00:00 2026-06-02T11:05:42+00:00

I have a huge program that I have spent 100+ hours on. It would

  • 0

I have a huge program that I have spent 100+ hours on. It would not work when I exported it even though it worked fine in Ecipse. I made a smaller program with just that code to test it out. I have searched and changed my code and I still can’t get my program to work when I export and run my jar file. It works great in Eclipse. I have tried file reader, stream, buffer, standing on my head, and changed to anything I have seen online about reading a file that is included in the jar file. I am new to coding so some things still confuse me. I changed the .java to .zip and looked at the pieces and the file is in there.

My read code is

private void readFile(){
    try {
        System.out.println("starting array");       
        String[] myarray;  
        myarray = new String[5];  
        System.out.println("myarray"+myarray);  
        url = getClass().getResource("classifyinginfo.txt"); 
        System.out.println("url is "+url);
        readbuffer = new BufferedReader(new FileReader(url.getPath()));          
        line1 = readbuffer.readLine();
        line1 = readbuffer.readLine();                  
        line1 = readbuffer.readLine();                  
        line1 = readbuffer.readLine();                                      
        { String splitarray[] = line1.split(",");
            firstentry = splitarray[0];
            myarray[0]=splitarray[3];
            myarray[1]=splitarray[4];
            myarray[2]=splitarray[5];
            myarray[3]=splitarray[6];
            myarray[4]=splitarray[7]; 

            //line2 and 3 readbuffer etc

            Arrays.sort(myarray);
            for(int i=0; i < myarray.length; i++){
                System.out.println(myarray[i]);

                textArea.append(myarray[i]+"\n");}
        }       


        System.out.println(Arrays.toString(myarray)); 
        //  textArea.setText(Arrays.toString(myarray));


        readbuffer.close(); } catch (IOException e) {
        System.out.println("we have an error");}           
    System.out.println("Line: " + line1 );
} 

please please tell me how to make this work in and out of Eclipse.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:05:44+00:00Added an answer on June 2, 2026 at 11:05 am

    You just do like this:

    url = getClass().getResource("classifyinginfo.txt"); 
    readbuffer = new BufferedReader(new InputStreamReader(url.openStream()));          
    line1 = readbuffer.readLine();
    

    The FileReader class can read individual files on disk, and that’s all. But you don’t need to use it once you have a URL. Modified in this way, the program will work whether the file is in a jar or not.

    You can actually eliminate the URL altogether and just do this:

    readbuffer =
        new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("classifyinginfo.txt")));          
    line1 = readbuffer.readLine();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C program that mines a huge data source (20GB of raw
I have to create a C# program that deals well with reading in huge
I have a program that reads a huge text file (line by line) and
I have a program that has to declare a huge integer array of the
I am writing a program that has to copy a sizeable, but not huge
At work, I have started working on a program that can potentially generate hundreds
I have a program that deals with huge amount of data. The process is
I have a program that streams media, which creates two huge MemoryStreams, and then
So I have a huge program and decided I should make one of the
I have a huge IQueryable that I want to export directly to Excel for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.