How to add a Java Properties file to my Java Project in Eclipse

前端 未结 8 888
[愿得一人]
[愿得一人] 2020-12-15 20:22

I was using Unix before to compile and edit my Java. In that I have used property files right inside my current working directory where the class file exists. Now i have swi

相关标签:
8条回答
  • 2020-12-15 20:34

    In the package explorer, right-click on the package and select New -> File, then enter the filename including the ".properties" suffix.

    0 讨论(0)
  • 2020-12-15 20:36

    It should work ok as it is in Unix, if you have properties file in current working directory. Another option would be adding your properties file to the classpath and getting the inputstream using this.getClass().getClassLoader().getResourceAsStream("xxxxx.properties"); More here

    0 讨论(0)
  • 2020-12-15 20:43

    steps:

    1. Right click on any package where you want to create your .properties file or create a new package as required
    2. now select new then select file (if you dont find file then go to location of your package and create it there)
    3. now named it as yourfilename.properties
    0 讨论(0)
  • 2020-12-15 20:47

    If you have created a Java Project in eclipse by using the 'from existing source' option then it should work as it did before. To be more precise File > New Java Project. In the Contents section select 'Create project from existing source' and then select your existing project folder. The wizard will take care of the rest.

    0 讨论(0)
  • 2020-12-15 20:52

    To create a property class please select your package where you wants to create your property file.

    Right click on the package and select other. Now select File and type your file name with (.properties) suffix. For example: db.properties. Than click finish. Now you can write your code inside this property file.

    0 讨论(0)
  • 2020-12-15 20:54

    If you are working with core java, create your file(.properties) by right clicking your project. If the file is present inside your package or src folder it will throw an file not found error

    0 讨论(0)
提交回复
热议问题