About the Java Interface
The API consists of a JAR file (StyleVisionServer.jar) and a JNI file (StyleVisionServer.dll). Both these files, as well as other related API files, are available in the bin folder of the StyleVision Server installation folder. You can either reference these files from their original location or copy them to another location if this fits your project setup. (On Windows systems, you will need administrative rights to run the program from its original location.)
Note: | If you have installed a 64-bit StyleVision Server, then the 32-bit version files of StyleVisionServer.jar and (StyleVisionServer.dll will be located in the bin\API_32bit folder of the StyleVision Server installation folder. You would need these files if you are using a 32-bit Java version. Similarly, if you have installed a 32-bit StyleVision Server, then the 64-bit version files of StyleVisionServer.jar and (StyleVisionServer.dll will be located in the bin\API_64bit folder. You would need to use these files if you are using a 64-bit Java version. |
To access the StyleVision Server API from Java code, add the following references to the .classpath file of your Java project.
StyleVisionServer.jar The library that communicates with StyleVision Server
StyleVisionServer_JavaDoc.zip Documentation of the StyleVision Server API
Additionally, the java.library.path needs to include the folder where the JNI library file (StyleVisionServer.dll) is located.
If you deploy your project to an application server, make sure that StyleVisionServer.jar and StyleVisionServer.dll are correctly configured with Java on the server machine.
For an example of how to use the API's library files, see the example batch file buildAndRun.bat (listed below), which is located in the etc\Examples\Java folder of your StyleVision Server installation folder.
Build and run a Java program to use the API
For guidance about how to build and run a Java program that uses the StyleVision Server API, see the example batch file buildAndRun.bat. You can re-use this file to run your own Java programs by modifying it as required.
Start the batch file in a command line interface with the following command:
buildAndRun "path_to_Java_bin_folder"
Note: | To check whether Java is in your classpath, you can run the command java --version. If Java is not in your classpath, then you must provide the path to it as a parameter of the buildAndRun command. If the path contains spaces, then uses quotes around teh path. |
@echo off if %1.==. goto error
REM The location of the JAVA API binaries, the JAR file and the JNI library. REM Adapt to your needs. SETLOCAL Set JavaAPIBinPath=%PROGRAMFILES%\Altova\StyleVisionServer2024\bin
REM Compile sample java REM The -cp option (classpath) needs to point to the installed jar file (here, in its original location) REM "Program.java" is the Java program you want to compile %1\javac.exe -cp "%JavaAPIBinPath%\StyleVisionServer.jar" Program.java
REM Run sample java REM The -cp option (classpath) needs to point to the StyleVisionServer.jar file REM The java.library.path needs to include the folder where the JNI library StyleVisionServer.dll is located. %1\java.exe -cp "%JavaAPIBinPath%\StyleVisionServer.jar;." -Djava.library.path="%JavaAPIBinPath%" Program
@echo off goto end
:error echo Usage: buildAndRun "<path_to_java_bin_folder>"
:end |
Adding library references in Eclipse
In Eclipse, you can add the classpath references by editing the properties of the Java project. The sample instructions below apply to Eclipse 4.4.
1.With the project open in Eclipse, on the Project menu, click Properties, and then select the Java Build Path.
2.On the Libraries tab, click Add External JARs, and then browse for the StyleVisionServer.jar file located in the StyleVision Server installation folder.
3.Under JARs and class folders on the build path, expand the StyleVisionServer.jar record, and then double-click the Javadoc location: (None) record.
4.Ensure that the Javadoc in archive and External file options are selected, and then browse for the StyleVisionServer_JavaDoc.zip file located in the StyleVision Server installation folder.
5.Click OK. The reference to the StyleVision Server library and Javadoc archive is added to the .classpath file of the project.