Compiling and Running an Application
Scenario
After the code development is complete, you can run an application in the Windows development environment.
If the network between the local and the cluster service plane is normal, you can perform the commissioning on the local host.
Procedure
- (Option) If the SmallFS code is used, need to set the fs.defaultFS parameter in core-site.xml file. The value should start with "sfs://".
<property> <name>fs.defaultFS</name> <value>sfs://hacluster</value> </property>In the HdfsExample.java example code file, add the following statements for reading smallFS configuration files:
// private static String PATH_TO_SMALL_SITE_XML = // HdfsExample.class.getClassLoader().getResource("smallfs-site.xml").getPath(); // conf.addResource(new Path(PATH_TO_SMALL_SITE_XML)); - In a development environment (such as IntelliJ IDEA), choose the following two projects separately and run the projects:
- Choose HdfsExample.java and right-click the project and choose from the shortcut menu to run the project.
- Choose ColocationExample.java and right-click the project and choose from the shortcut menu to run the project.
- Do not restart HDFS service while HDFS application is in running status, otherwise the application will fail.
- To use SmallFS example code, choose and run HdfsExample.java.
- When the Colocation project is run, the HDFS parameter fs.defaultFS cannot be set to viewfs://ClusterX.
Note
During security authentication, Hadoop needs to obtain the domain name of the host where the client is located (Default Realm, which is obtained from environment variable USERDNSDOMAIN). If the host does not have a domain name, the following error message is displayed when you run the sample program:

You can set environment variable USERDNSDOMAIN of the system to prevent this problem. The details are as follows:
- Right-click Computer and choose Properties from the shortcut menu. The dialog box shown in the following figure is displayed. Click Advanced system settings > Advanced > Environment Variables.
- Set the system environment variable and click "New". The New System Variable dialog box is displayed. Enter USERDNSDOMAIN in Variable name and set the Variable value to a non-null character string, for example, test.
Click OK twice. The system environment variable is set.

- Close the sample project, open it again, and run it.
Last Article: Commissioning an Application in the Windows Environment
Next Article: Checking the Commissioning Result
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.