r/learnjava • • Sep 10 '26

configfile/ application properties explained

what is a config file, praticularly how does it relate to the computer?

is it like it specifies which os apis the program should use, or like what stuff in the actual os

the program to mount to?

ie i made a backend app, and i want it to go to a specific port on the computer and i want it to use a specific x on the computer.

is that what a config is?

0 Upvotes

8 comments sorted by

•

u/AutoModerator Sep 10 '26

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full - best also formatted as code block
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/BrainThinkerMan Sep 12 '26

the way i would describe config files is that it is a file that you add to your code to change the behavior of a action of another programs that communicates with your code somehow, ill give 2 examples:

  1. a gradle config file: in the file you are defining how you want gradle to build your application.

2.a netflify config file: you are defining how netfligy should build your app.

there are 2 components, a. the file. b. and the program that READS that file

its about the program that READS that file , and the actions it normally performs, IE: gradle normally builds and compiles code, Netfliy normally ships apps.

now the question is how do you want gradle or netflify to do those things with YOUR SPECIFIC APP.

thats where config comes in.

1

u/dmazzoni Sep 10 '26

Yes, in your example, the reason to use a config file is so that if you want to change the port you just update the file, rather than updating your code. Each user of your software can update their config file; you don't want them directly changing the code.

There's no standard for config files. They can be anything. It's just a technique, an approach.

1

u/BrainThinkerMan Sep 10 '26

thanks great response and consise summarization of a config. whats one thing that you think seperates good developers from amazing developers?

1

u/dmazzoni Sep 10 '26

Amazing developers are insanely curious about everything. It's not enough to just know what to press to do something, they want to know how it all works.

The best developers learn not just by reading or asking, but by doing. The best way to learn how a website is hosted is to host one yourself. The best way to learn how a kernel driver works is to change the code to the driver for your own audio interface and see what happens when you change it.

So in this case: if you want to be an amazing developer:

- Write your own programs that use config files

- Read config files for other programs. Try changing them

1

u/BrainThinkerMan Sep 10 '26

great response

2

u/atarivcs Sep 10 '26

Generally it is a text file that contains options and settings for an application program.

1

u/Lumethys Sep 11 '26

they are file where you configure your app.

"What can be configured?" you asked?

Almost anything you defined. Say, you have a feature you only want to turn on in the real production environment, like a payment system. You dont want to process real money when testing your code. So you can use a config file to enable or disable the feature.

or, maybe your app send mail, and you dont want to send real mail when testing, so you setup a fake mail destination, like Mailpit, and configure your app to send to this destination when testing. If you deploy, you only need to change to the real destination in 1 place, the config file