This example will help you integrate ONLYOFFICE Docs into your web application written in Java.
Please keep in mind the following security aspects when you are using test examples:
Download and install ONLYOFFICE Docs (packaged as Document Server):
See the detailed guide to learn how to install ONLYOFFICE Docs for Windows.
Download the Java example from our site.
To connect the editors to your website, specify the path to the editors installation and the path to the storage folder in the src/main/resources/settings.properties file:
storage-folder = app_data files.docservice.url.site=https://documentserver/
where the documentserver is the name of the server with the ONLYOFFICE Docs installed and the storage-folder is the path where files will be created and stored. You can set an absolute path. For example, D:\\folder. Please note that on Windows OS the double backslash must be used as a separator.
If you want to experiment with the editor configuration, modify the parameters in the src/main/webapp/editor.jsp file.
To run the Java example code, install the Java version appropriate for your OS and web server Apache Tomcat:
After you have installed Java on Windows, set the JAVA_HOME environment variable to point to the Java installation directory.
Find out where Java is installed. If you didn't change the path during installation, it will be something like this:
C:\Program Files\Java\jdk1.8.0_65
In Windows 7, right click My Computer and select Properties, then click Advanced.
In Windows 8, go to Control Panel and select System, then click Advanced System Settings.
Click the Environment Variables button.
Under System Variables, click New.
In the Variable Name field, enter JAVA_HOME if you installed the JDK (Java Development Kit) or JRE_HOME if you installed the JRE (Java Runtime Environment).
In the Variable Value field, enter your JDK or JRE installation path, for example C:\Program Files\Java\jdk1.8.0_65.
Check if the variable created successfully by echo command in the Command Prompt:
echo %JAVA_HOME%
Run the Command Prompt. Change the current directory for the Apache Tomcat installation directory:
cd /d C:\Apache Tomcat\apache-tomcat-7.0.67\bin
Use the bin startup.bat script to start Apache Tomcat:
startup.bat
You will see the new Tomcat console window displayed that provides the information and messages about Tomcat startup:
Test your Tomcat installation using the address in a web browser:
If everything is correct, you will see the Tomcat web page in the browser as shown below.
Open Tomcat Web Application Manager by clicking Manager App:
Tomcat Web Application Manager will request the username and the password:
Specify user data in tomcat-users.xml file in the Apache Tomcat installation folder. Define the manager-gui user role, specify the user name and password values:
<tomcat-users> <role rolename="manager-gui"/> <user username="tomcat" password="tomcat" roles="manager-gui"/> </tomcat-users>
Upload the Java project in Tomcat Web Application Manager. For that click Choose File in the WAR file to deploy section and find the .war file in the Java project folder, then click Deploy.
You will see the project in the Application List:
Click the link with the application name to run it.
In case the example and ONLYOFFICE Docs are installed on different computers, make sure that your server with the example installed has access to the ONLYOFFICE Docs with the address which you specify instead of documentserver in the configuration files. Make sure that the ONLYOFFICE Docs in its turn has access to the server with the example installed with the address which you specify instead of example.com in the configuration files.
If you integrated the editors successfully the result should look like the demo preview on our site.
Download and install ONLYOFFICE Docs (packaged as Document Server):
See the detailed guide to learn how to install ONLYOFFICE Docs for Linux.
Edit the following lines:
storage-folder = app_data files.docservice.url.site=https://documentserver/
where the documentserver is the name of the server with the ONLYOFFICE Docs installed and the storage-folder is the path where files will be created and stored. Please note that you must have read and write permissions to the folder. If you do not have them, please use the next command:
sudo chmod -R ugo+rw /{path}
<role rolename="manager-gui"/> <user username="USERNAME" password="PASSWORD" roles="manager-gui"/>
where the USERNAME and PASSWORD are your own credentials data.
Restart Tomcat:In case the example and ONLYOFFICE Docs are installed on different computers, make sure that your server with the example installed has access to the ONLYOFFICE Docs with the address which you specify instead of documentserver in the configuration files. Make sure that the ONLYOFFICE Docs in its turn has access to the server with the example installed with the address which you specify instead of example.com in the configuration files.
If you integrated the editors successfully the result should look like the demo preview on our site.
Download and install ONLYOFFICE Docs (packaged as Document Server):
See the detailed guide to learn how to install ONLYOFFICE Docs for Docker.
Edit the following lines:
storage-folder = app_data files.docservice.url.site=https://documentserver/
where the documentserver is the name of the server with the ONLYOFFICE Docs installed and the storage-folder is the path where files will be created and stored.
In case the example and ONLYOFFICE Docs are installed on different computers, make sure that your server with the example installed has access to the ONLYOFFICE Docs with the address which you specify instead of documentserver in the configuration files. Make sure that the ONLYOFFICE Docs in its turn has access to the server with the example installed with the address which you specify instead of example.com in the configuration files.
If you integrated the editors successfully the result should look like the demo preview on our site.