Idea logo

The IntelliJ IDEA Blog

The Capable & Ergonomic Java IDE by JetBrains


Control your Perforce connection

In IntelliJ IDEA 10.5 we’ve improved setting up your Perforce server connection and connection state diagnostics.

Configuring connections

If you are using P4CONFIG files for configuration, IntelliJ IDEA shows what config files it has found and what other default settings are used. This way you can be sure that your P4CONFIG files are found and taken into account.

Use the ‘Test Connection’ button in ‘Settings | Version Control | VCSs | Perforce’ to see this information.

Moreover, in case you specified a wrong client workspace and your project roots do not match with the workspace roots, you are also clearly prompted:

Perforce connection parameters dialog

If you are not authenticated to the server or the authentication ticket has expired, you will be notified accordingly:
Not logged to Perforce notification

Offline mode

Once Perforce server becomes unavailable, IntelliJ IDEA switches to the offline mode automatically and displays an offline notification.
"Perforce is offline" notification

In the offline mode, you can continue working locally as usual, file checkouts are remembered by IntelliJ IDEA to be further re-played. When going online IntelliJ IDEA requires that you authenticate on the server and the ticket is not expired. This is important to re-play you offline edits properly.

Comments below can no longer be edited.

24 Responses to Control your Perforce connection

  1. Avatar

    Alexander Chuprin says:

    June 1, 2011

    How i can define perforce executable path globally for all projects? Not per one.
    Now i need to do it for every created project.

  2. Avatar

    Fredrik says:

    June 1, 2011

    Good stuff, thanks!

  3. Avatar

    Vampire says:

    June 1, 2011

    @Alexander Chuprin: Configure it in the default settings, then it is filled in automatically if you create a new project. Either go to the settings while no project is open or go to “File -> Other Settings -> Template Setting”

  4. Avatar

    Irina Chernushina (JetBrains) says:

    June 1, 2011

    @Alexander: Close all projects, go to Settings, and change perforce executable path (it will change it for default project settings).
    After that, every new project will be created with this setting.

    For existing projects you can only change them one-by-one.

  5. Avatar

    pmac says:

    June 1, 2011

    Hi – this sounds good. An unrelated question: Is it possible to associate different P4 clients with different intelliJ modules? Or is a P4 client 1-to-1 with an intelliJ project?

  6. Avatar

    Irina Chernushina (JetBrains) says:

    June 1, 2011

    @pmac No, you define P4 client executable on the project level. Why do you need that on module level?

  7. Avatar

    Luke says:

    June 1, 2011

    I just ran across this functionality yesterday – very useful stuff.

  8. Avatar

    pmac says:

    June 2, 2011

    @Irina Our build system enforces that we have certain modules in certain P4 clients, based on dependency. So I have a ‘core’ client with low-level modules, and an ‘apps’ client, which uses stuff in ‘core’. That’s just how it works, but maybe that is highly unusual. I, for one, would love to be able to have one project with some modules using ClientA and some using ClientB.

  9. Avatar

    Irina Chernushina (JetBrains) says:

    June 2, 2011

    @pmac Did you mean P4CLIENT setting?

  10. Avatar

    pmac says:

    June 3, 2011

    Yep – so I have have two P4 Clients. Some modules in my intelliJ project map to ClientA and some map to ClientB, but so far as I can tell, intelliJ expects all modules in a project to map to one client, so I must choose to manage either ClientA or ClientB through intelliJ, but not both.

  11. Avatar

    Irina Chernushina (JetBrains) says:

    June 3, 2011

    @pmac You can use P4CONFIG files with IDEA.
    Define 2 files – one with parameters for clientA, another for clientB.
    (Either define P4CONFIG variable
    or use default name (p4config for Windows, .p4config for other OS))
    Put this files into root directories of your modules, or in any directory above.
    In settings (Settings -> Version Control -> VCSs -> Perforce) define that P4CONFIG or default connection will be used.
    Check that your config files are found by IDEA with Test Connection button.

  12. Avatar

    pmac says:

    June 3, 2011

    Irina, thank you very much! That’s fantastic.

  13. Avatar

    Jim C. says:

    September 27, 2011

    So what I have is a perforce workspace shared across Linux and Windows. On windows, it is mounted at -> Z:p4ws[client_name], however my InteliJ IDEA workspace is C:Usersjamescolworkspace. The IntelliJ workspace is where I am keeping the *.iml files etc. I have both set up so that C:Usersjamescolworkspace has no version control specified and Z:p4ws[client_name] has perforce specified. The client was originally created on Linux. The maven project imports without incident.

    Now to the problem: On each connection attempt, I get Client Unknown. The p4v GUI sees everything fine. I noticed that the p4config file spec displayed is Z:/p4ws/client_name in the display but what I entered was Z:p4wsclient_name (windows backslashes).

    Any hints I can get? I really need this to run on Windows as there are like 20 some odd servers running on the Linux box.

  14. Avatar

    Jim C. says:

    September 30, 2011

    Figured this out. In the P4CONFIG file there is a P4PORT setting that is actually HOST:PORT rather than just port.

  15. Avatar

    Bill R says:

    October 31, 2011

    We have a tree checked out of P4 that had a tree of files checked out to be writable, so when making changes in IJ, it was not asking to check out under p4. So we created a new p4 workspace, and loaded that into IJ and set VC=P4, verifying that the connection is good. Now on making a change to a file, it asks whether to check out, but when it tries to, it complains that the file is not under the client’s root, giving the root+path of the file under the original workspace.

    What to do?

  16. Avatar

    Bill R says:

    October 31, 2011

    Followup: this is on Win7. We had tried setting P4CLIENT to the name of the new workspace in the User env variables, but this didn’t work. However when we set the same in the System variables, things are now working ok.

  17. Avatar

    miles zarathustra says:

    November 21, 2012

    My perforce used to work just fine in IntelliJ, but recently (I forget when) it stopped working.

    Looking into it now, I see that it says “no config file.” Yet, P4CONFIG is defined properly and there is indeed a config file IN THE PROJECT DIRECTORY. So I guess you all changed where it looks for the config?

    If I use p4 from the command line within the project directory, it works fine. Idea can’t figure it out any more, but it used to be able to. Now I will configure P4 by hand in the idea project. Painful.


  18. Avatar

    miles zarathustra says:

    November 21, 2012

    AND … your captchas are obnoxious! If you miss (which is easy to do) it deletes the message.
    🙁 🙁

  19. Avatar

    Peter Gromov says:

    November 21, 2012

    miles zarathustra, please file a YouTrack ticket about this issue.

  20. Avatar

    rohit says:

    January 4, 2013

    my project root and perforce workspace do not match. I have set up only a portion of my perforce workspace in idea. On testing connection it says wrong client specification. how can I integrate my project with perforce. Moreover is there a way to integrate only one module with perforce ?

  21. Avatar

    Peter Gromov says:

    January 10, 2013

    rohit, could you please file a YouTrack request ( with some screenshots illustrating the problem?

  22. Avatar

    RLop says:

    November 13, 2015

    I am getting below error when trying to connect from IntelliJ to Perforce.
    P4V: unrecognized option ‘-zprog=IntelliJ_IDEA_info’
    try ‘/Applications/ -help’ for more information.

    As far as I can tell, I have setup all the connection parameters right. What am I missing.

    • Avatar

      Peter Gromov says:

      November 14, 2015

      RLop, it seems that you’ve entered the path to “p4v” where “p4” is expected, in the Perforce settings of the IDE.

      • Avatar

        ashok says:

        April 7, 2017

        Thanks for your help , i was not able to work from so many days .
        but u done it .

Discover more