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

  • SEARCH
  • Home
  • 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 9136055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:54:10+00:00 2026-06-17T08:54:10+00:00

I need the properties changes made programatically to persist a server reboot, redeployment, ect.

  • 0

I need the properties changes made programatically to persist a server reboot, redeployment, ect. Basically, I need modify the properties file when changes are made. Is this even possible? Currently, I have the properties working but the values dont ever change in the properties folder.

            String realPath = getPortletContext().getRealPath("/");

        FileInputStream in = new  FileInputStream(realPath+"json.properties");



        Properties p = new Properties();
        p.load(in);

        System.out.println(p.getProperty("json"));

              in.close();
        p.setProperty("json", "test");
        System.out.println(p.getProperty("json"));

        FileOutputStream out = new FileOutputStream(realPath+"json.properties");
        p.store(out, "test");
        in.close();

       out.close(); 

       System.out.println(com.liferay.util.portlet.PortletProps.get("json"));
       com.liferay.util.portlet.PortletProps.set("json", "change");
       com.liferay.util.portlet.PortletProps.set("new", "change");
       System.out.println(com.liferay.util.portlet.PortletProps.get("new"));

portal.properties:

json=help
new=new1

json.properties

json=blank

output when code is ran:

blank
test
help
change

As you can see above, I have tried using regular java properties and tried using the liferay properties. I need to basically need to get some json, edit it, then save it for later use. I need the changes to persist until edited again.

  • 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-17T08:54:11+00:00Added an answer on June 17, 2026 at 8:54 am

    All of my previous code is junk the way I solved it was to use

                PortletPreferences portletPreference = actionRequest.getPreferences();
    
            portletPreference.setValue("help", "me");
            portletPreference.store();
    

    Note: I tried this before with no luck and the problem was my imports. make sure that you use
    javax.portlet.PortletPreferences; and not the liferay portletpreferences class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I made a bunch of changes to my local svn config file. Mainly
I need to watch properties for changes. Which method is better in terms of
I need to change some custom properties values in many files. Here is an
I have two objects List<Report> List<Newsletter> I need certain properties like Id Date Status
I have a scenario where I need to load properties from database or java
I need to get a Properties object into my spring bean so I can
I need inherit events and properties. For example, I need to move a picture
I need to create a class with two properties: LogOutput ExceptionOutput These properties (Actions<>)
I need to assign values to properties through reflection, and it has been OK
I need to recursively go through all properties in my class and if the

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.