|
1 | 1 | --- |
2 | 2 | id: how-to-run-examples |
3 | 3 | url: conversion/nodejs-java/how-to-run-examples |
4 | | -title: How to run examples |
| 4 | +title: How to Run Examples |
5 | 5 | weight: 6 |
6 | | -description: "This article describes how to run Node.js file conversion API code examples." |
7 | | -keywords: file conversion, node.js |
| 6 | +description: "Learn how to clone, configure, and run GroupDocs.Conversion for Node.js via Java example projects." |
| 7 | +keywords: How to run a conversion, basic usage, How to run examples |
8 | 8 | productName: GroupDocs.Conversion for Node.js via Java |
9 | 9 | hideChildren: False |
10 | 10 | toc: True |
11 | 11 | --- |
12 | | -The complete [GroupDocs.Conversion Examples](https://github.com/groupdocs-conversion/GroupDocs.Conversion-for-Node.js-via-Java) project with code examples and sample files is hosted on GitHub. |
13 | 12 |
|
| 13 | +The complete project [GroupDocs.Conversion for Node.js via Java — Code Examples](https://github.com/groupdocs-conversion/GroupDocs.Conversion-for-Node.js-via-Java) with runnable examples and sample files is hosted on GitHub. The structure and commands below are based on this repository and its README. |
14 | 14 |
|
15 | | -## Run examples using NPM |
| 15 | +## Prerequisites |
16 | 16 |
|
17 | | -To get started make sure that [Node.js](https://nodejs.org) is installed. |
| 17 | +Before running examples, make sure your environment meets the [System Requirements]({{< ref "conversion/nodejs-java/getting-started/system-requirements" >}}) and [Installation]({{< ref "conversion/nodejs-java/getting-started/installation" >}}) guides: |
18 | 18 |
|
19 | | -1. Clone repository with examples `git clone https://github.com/groupdocs-conversion/GroupDocs.Conversion-for-Node.js-via-Java.git` |
20 | | -2. Navigate to the project folder `cd ./GroupDocs.Conversion-for-Node.js-via-Java` |
21 | | -3. Install the necessary packages with the `npm install` command. |
22 | | -4. Navigate to the examples folder `cd ./Examples` |
23 | | -4. Run the examples with the `node runExamples.js` command. |
| 19 | +- **Node.js**: 20 LTS or later |
| 20 | +- **Java**: JRE/JDK 8+ (17 LTS recommended) |
| 21 | +- **Java environment**: `JAVA_HOME` set and added to `PATH` |
24 | 22 |
|
25 | | -To check what examples are available open `Examples/runExamples.js` file using your favorite text editor. Uncomment examples that you want to run and type `node runExamples.js` to start them. |
| 23 | +Windows PowerShell: |
26 | 24 |
|
| 25 | +```powershell |
| 26 | +$env:JAVA_HOME="C:\Program Files\Java\jdk-17" |
| 27 | +$env:Path="$env:JAVA_HOME\bin;$env:Path" |
| 28 | +``` |
27 | 29 |
|
28 | | -## Contribute |
| 30 | +Linux/macOS: |
29 | 31 |
|
30 | | -If you like to add or improve an example, we encourage you to contribute to the project. All examples in this repository are open source and can be freely used in your own applications. |
| 32 | +```bash |
| 33 | +export JAVA_HOME=/usr/lib/jvm/java-17 |
| 34 | +export PATH=$JAVA_HOME/bin:$PATH |
| 35 | +``` |
31 | 36 |
|
32 | | -To contribute, you can fork the repository, edit the source code and create a pull request. We will review the changes and include them in the repository if found helpful. |
| 37 | +For more details, see the examples repository README: |
| 38 | +[GroupDocs.Conversion for Node.js via Java — Code Examples README](https://raw.githubusercontent.com/groupdocs-conversion/GroupDocs.Conversion-for-Node.js-via-Java/refs/heads/master/README.md). |
| 39 | + |
| 40 | +## Run examples using npm |
| 41 | + |
| 42 | +To get started, make sure that [Node.js](https://nodejs.org/) and Java are installed and configured as described above. |
| 43 | + |
| 44 | +1. **Clone the repository with examples** |
| 45 | + |
| 46 | + ```bash |
| 47 | + git clone https://github.com/groupdocs-conversion/GroupDocs.Conversion-for-Node.js-via-Java.git |
| 48 | + cd GroupDocs.Conversion-for-Node.js-via-Java |
| 49 | + ``` |
| 50 | + |
| 51 | +2. **Install dependencies** |
| 52 | + |
| 53 | + ```bash |
| 54 | + npm install |
| 55 | + ``` |
| 56 | + |
| 57 | + This installs the bundled `groupdocs-conversion-<version>.tgz` package and other dependencies defined in `package.json`. |
| 58 | + If installation fails with native build errors, review the build tools section in [System Requirements]({{< ref "conversion/nodejs-java/getting-started/system-requirements" >}}). |
| 59 | + |
| 60 | +3. **Run all examples** |
| 61 | + |
| 62 | + ```bash |
| 63 | + npm start |
| 64 | + ``` |
| 65 | + |
| 66 | + Output documents are created under the `./Examples/Output/` directory |
| 67 | + |
| 68 | +## Explore available examples |
| 69 | + |
| 70 | +After running the project once, you may want to see what examples are available and how they are organized: |
| 71 | + |
| 72 | +- Open `examples.js` and `runExamples.js` to review the list of functions being called. |
| 73 | +- Enable or disable specific examples by editing `runExamples.js` and re-running: |
| 74 | + |
| 75 | + ```bash |
| 76 | + npm start |
| 77 | + ``` |
| 78 | + |
| 79 | +Refer to the examples [README](https://github.com/groupdocs-conversion/GroupDocs.Conversion-for-Node.js-via-Java) for an overview of QuickStart, BasicUsage, and AdvancedUsage folders and the scenarios they cover. |
0 commit comments