NetBeans: automatic upload to FTP

NetBeans IDE supports the ability to upload files to your local project to a remote FTP-server.
To configure this feature, you must right-click on the name of your project and choose from context menu "Properties", a window will appear with the settings of the project.

In the left menu you must select the section "Run Configuration".
Next deal directly setting the parameters:
Change the value of the "Run As" to "Remote Web Site (FTP, SFTP)".

Right from the drop-down list "Remote Connection" there is a button "Manage ..." for FTP control connections, click on it. Window opens manage connections, you must create a new connection to the bottom of this click on a button "Add", specify a custom name for the new connection and select its type - FTP or SFTP (type depends on which type of connection uses the hosting provider), press on "OK".

Added a new connection, you must set its parameters, fill in the appropriate fields (host, username, password).

Next is a very important parameter "Initial Directory", here defined path to the folder where are all your sites on a server, for example, you have a dedicated hosting all your sites are stored in the directory "/var/www", and it must be specified in this parameter, in all other cases, you must specify only one slash "/", which will link directly to the root.

Then all leave as is, except for the case when you choose to normal FTP (not SFTP), you can tick the option "Passive Mode" (if it will not work - remove it).

Now let's test our connection by pressing down on the button "Test Connection", if the result is "Connection Succeeded", then you specify the correct data, otherwise check the correctness of the data entered.

If the test, press the bottom of the "OK" button, we will return back to the project settings, now we can choose from a drop-down list setting "Remote Connection" is the connection that we just created.

Next is the last important option - "Upload Directory", here we have to specify the path to the folder on the FTP, which is necessary to make downloading files, here are some important points:
  • Path where NetBeans will upload files will be equal to the option "Initial Directory" of the connection settings + option "Upload Directory" of the project settings.
  • If the path "Initial Directory" is slash "/", then in the option "Upload Directory" specify the path that leads to the root of your site, for example, you can open the FileZilla in the root of your website (with our connection settings), and copy the path of the line "Remote Site".
For example, your site is on the way to the FTP "/var/www/mysite.com/httpdocs", then the parameter "Initial Directory" is equal to "/var/www", and the parameter "Upload Directory" will be equal to "/mysite.com/httpdocs ".

If the parameter "Initial Directory" is specified as "/", then "Upload Directory" you must specify the full path from the root FTP - "/var/www/mysite.com/httpdocs".

Why such troubles? Very simple - you can use the same connection for various projects, showing them a different "Upload Directory".

And the last option "Upload Files" determines which event to boot on the FTP, three options:
  • Manyally - manually, it requires self-right-click on the file/folder of your project and select "Upload", a window will appear confirming upload files to FTP.
  • On Run - when the project starts, to be honest it never did not use, but I understand the files will be uploaded to FTP when you right-click the project or file and select "Run".
  • On Save - while retaining the most convenient way, you just edit the file, press Ctrl + S and your changes immediately fly to FTP.
That's it, push down on the "OK" and use))

Comments (0)


Leave a comment