Skip to content

Commit

Permalink
Update documentation and dependencies (#130)
Browse files Browse the repository at this point in the history
* Update documentation

* Upgrade dependencies

---------

Co-authored-by: kaklakariada <[email protected]>
  • Loading branch information
kaklakariada and kaklakariada authored Feb 3, 2024
1 parent af379b1 commit 0101792
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 60 deletions.
1 change: 1 addition & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=ignore
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
org.eclipse.jdt.core.codeComplete.fieldPrefixes=
Expand Down
7 changes: 4 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
".idea/": true,
},
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit",
"source.fixAll": "explicit"
},
"java.codeGeneration.useBlocks": true,
"java.configuration.updateBuildConfiguration": "automatic",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modificationsIfAvailable",
"sonarlint.connectedMode.project": {
"connectionId": "itsallcode",
"projectKey": "white-rabbit"
"connectionId": "kaklakariada-github",
"projectKey": "com.github.kaklakariada:portmapper"
}
}
83 changes: 47 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ See [CHANGELOG.md](CHANGELOG.md) for changes in the new version.

[Download](http://sourceforge.net/projects/upnp-portmapper/files/latest/download) binaries from [SourceForge](http://sourceforge.net/projects/upnp-portmapper/).

### Install Java 11<a name="install_java"></a>
### Install Java

UPnP PortMapper requires JRE 11 (Java Runtime Environment) or later. I recommend you download OpenJDK 11 JRE from [AdoptOpenJDK](https://adoptopenjdk.net/releases.html?variant=openjdk11&jvmVariant=hotspot).
UPnP PortMapper requires JRE 11 (Java Runtime Environment) or later. I recommend you download the latest OpenJDK JRE from [AdoptOpenJDK](https://adoptium.net/temurin/releases/?package=jre).

For Windows please choose the `.msi` installer which will set the environment variable `JAVA_HOME` and add java to the `PATH`.
For Windows please choose the `.msi` installer which will set the environment variable `JAVA_HOME` and add Java to the `PATH`.

Verify that the installation was successful by running this command:

```bash
$ java -version
```
java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)
Expand All @@ -45,8 +45,8 @@ If you are still using Java 1.8 and can't upgrade to Java 11, you can use [PortM

To run PortMapper, double click on the JAR file or run

```bash
$ java -jar portmapper.jar
```sh
java -jar portmapper.jar
```

on the command line.
Expand All @@ -56,43 +56,52 @@ on the command line.
### General

- Update the firmware of your router to the latest version.
- Verify that your router supports UPnP and it is enabled in the settings.

### PortMapper fails to start

**Error 1**: When you double click `portmapper.jar`, an error dialog with the following message is displayed:
#### JNI error

When you double click `portmapper.jar`, an error dialog with the following message is displayed:

`A JNI error has occurred, please check your installation and try again`

**Error 2**: When you start PortMapper from the command line using `java -jar portmapper.jar` you get the following exception:
#### UnsupportedClassVersionError

When you start PortMapper from the command line using `java -jar portmapper.jar` you get the following exception:

`java.lang.UnsupportedClassVersionError: org/chris/portmapper/PortMapperStarter has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0`

Usually this means your Java version is outdated. Please [install Java 11 or later](#install_java).

Run `java -version` on the command line to check the default version. If this returns something else than Java 11, you can specify the complete path, e.g.:

```bash
```sh
"C:\Program Files\AdoptOpenJDK\jdk-11.0.3.7-hotspot\bin\java.exe" -jar portmapper.jar
```

If this does not help: run PortMapper from the command line using the command above and create a [ticket](https://github.com/kaklakariada/portmapper/issues) containing the complete error message and stack trace.

#### java.lang.ClassNotFoundException: /language=en

When starting PortMapper on the command line with JVM option `-Duser.language=en` you get the following error:

```
$ java -Duser.language=en -jar portmapper.jar
java -Duser.language=en -jar portmapper.jar
Error: Could not find or load main class .language=en
Caused by: java.lang.ClassNotFoundException: /language=en
```

This error occurs when using PowerShell to start PortMapper with a system property argument, e.g. `-Duser.language=en`. To fix this, enclose the system property in double quotes, e.g.:

```
$ java "-Duser.language=en" -jar portmapper.jar
```sh
java "-Duser.language=en" -jar portmapper.jar
```

#### java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

When starting PortMapper you get the following error message in the terminal:

```
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.chris.portmapper.PortMapperStarter.<clinit>(PortMapperStarter.java:26)
Expand All @@ -112,7 +121,7 @@ You probably try to run a `.jar` that does not contain the required dependencies

### Router not found

- Check if UPnP is activated in your router's settings.
- Check if your router supports UPnP and it is activated in your router's settings.
- Use a different UPnP library in the settings. Please note that `DummyRouterFactory` is just for testing.
- Check if a network bridge is active on your computer. Try to deactive it as it may [prevent detection of the router](https://sourceforge.net/p/upnp-portmapper/bugs/75/#54ef).
- Set Log level to `TRACE` in the settings, connect again and check the log.
Expand All @@ -126,8 +135,8 @@ If you can connect to your router from one device but not from another you can d
1. Get location URL on the machine that can connect to the router by clicking the `Info` button (look for something like `INFO - location = http://192.168.178.1:49000/igddesc.xml`)
1. Specify the location URL as a command line argument:

```bash
$ java "-Dportmapper.locationUrl=<locationurl>" -jar portmapper.jar -lib org.chris.portmapper.router.weupnp.WeUPnPRouterFactory <args>
```sh
java "-Dportmapper.locationUrl=<locationurl>" -jar portmapper.jar -lib org.chris.portmapper.router.weupnp.WeUPnPRouterFactory <args>
```

### Adding port forwardings not possible
Expand Down Expand Up @@ -187,7 +196,7 @@ If you use a tool to verify that a port forwarding works, please make sure to st
PortMapper also has a command line interface. You can see the available options by adding parameter `-h`:

```
$ java -jar portmapper.jar -h
java -jar portmapper.jar -h
-add : Add a new port mapping
-delete : Delete a new port mapping
-description VAL : Description of the port mapping
Expand All @@ -207,33 +216,33 @@ $ java -jar portmapper.jar -h

- Create a new port mapping for a specific IP address

```bash
$ java -jar portmapper.jar -add -externalPort <port> -internalPort <port> -ip <ip-addr> -protocol tcp
```
```sh
java -jar portmapper.jar -add -externalPort <port> -internalPort <port> -ip <ip-addr> -protocol tcp
```

- Create a new port mapping for the local machine (just omit the IP)

```bash
$ java -jar portmapper.jar -add -externalPort <port> -internalPort <port> -protocol tcp
```
```sh
java -jar portmapper.jar -add -externalPort <port> -internalPort <port> -protocol tcp
```

- Delete a port forwarding

```bash
$ java -jar portmapper.jar -delete -externalPort <port> -protocol tcp
```
```sh
java -jar portmapper.jar -delete -externalPort <port> -protocol tcp
```

- List existing port forwardings

```bash
$ java -jar portmapper.jar -list
```
```sh
java -jar portmapper.jar -list
```

- Specify a UPnP library (see below for available libraries)

```bash
$ java -jar portmapper.jar -lib org.chris.portmapper.router.weupnp.WeUPnPRouterFactory -list
```
```sh
java -jar portmapper.jar -lib org.chris.portmapper.router.weupnp.WeUPnPRouterFactory -list
```

### UPnP libraries

Expand All @@ -248,16 +257,18 @@ PortMapper includes three third party UPnP libraries. If the default does not wo

PortMapper is translated to English (`en`) and German (`de`). It automatically detects the operating system's language, using English as default. If you want use a different language, add command line option `-Duser.language=de` to java, e.g.:
```bash
$ java "-Duser.language=de" -jar portmapper.jar
```sh
java "-Duser.language=de" -jar portmapper.jar
```
Please note ensure to enclose the option with double quotes (`"`) in PowerShell, else the command will fail.
### Using a custom directory for configuration files
PortMapper stores its configuration as XML files in a folder. Under Windows this folder is located at `%AppData%\UnknownApplicationVendor\PortMapper\` (e.g. `C:\Users\<username>\AppData\Roaming\UnknownApplicationVendor\PortMapper`). You can change this folder by specifying a command line argument:
```bash
java -Dportmapper.config.dir=C:/path/to/config -jar portmapper.jar
```sh
java "-Dportmapper.config.dir=C:/path/to/config" -jar portmapper.jar
```
Create an empty directory before starting, else PortMapper will fail with an error message.
Expand Down
13 changes: 6 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
id "org.sonarqube" version "4.4.1.3373"
id 'com.github.johnrengelman.shadow' version '8.1.1'
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
id 'com.github.ben-manes.versions' version '0.48.0'
id 'com.github.ben-manes.versions' version '0.51.0'
}

repositories {
Expand Down Expand Up @@ -79,10 +79,10 @@ artifacts {

dependencies {
implementation 'args4j:args4j:2.33'
implementation 'org.slf4j:slf4j-api:2.0.9'
implementation 'org.slf4j:jul-to-slf4j:2.0.9'
implementation 'ch.qos.logback:logback-classic:1.4.11'
implementation 'com.miglayout:miglayout-swing:11.1'
implementation 'org.slf4j:slf4j-api:2.0.11'
implementation 'org.slf4j:jul-to-slf4j:2.0.11'
implementation 'ch.qos.logback:logback-classic:1.4.14'
implementation 'com.miglayout:miglayout-swing:11.3'
implementation 'org.jdesktop.bsaf:bsaf:1.9.2'
implementation ':sbbi-upnplib:1.0.4'
implementation 'org.fourthline.cling:cling-support:2.1.2'
Expand All @@ -91,7 +91,7 @@ dependencies {
runtimeOnly 'commons-jxpath:commons-jxpath:1.1' // sbbi

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:5.6.0'
testImplementation 'org.mockito:mockito-core:5.10.0'
}

license {
Expand All @@ -109,7 +109,6 @@ sonar {
properties {
property("sonar.organization", "kaklakariada-github")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.gradle.skipCompile", "true")
}
}

Expand Down
6 changes: 3 additions & 3 deletions doc/developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ PortMapper is available as a Maven dependency at [Maven Central](https://repo1.m

Build PortMapper on the command line:

```bash
```sh
git clone https://github.com/kaklakariada/portmapper.git
cd portmapper
./gradlew build
Expand All @@ -31,13 +31,13 @@ java -jar build/libs/portmapper-*.jar

## Generate license header for added files

```bash
```sh
./gradlew licenseFormat
```

## Check if dependencies are up-to-date

```bash
```sh
./gradlew dependencyUpdates
```

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down

0 comments on commit 0101792

Please sign in to comment.