text:
Q: How do I get my Kotlin Spring Boot project to run using java command? Using IntelliJ, I can get my Kotlin (JVM) project to run. However, when I try to run it using java command, it fails.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>org.cas.eo.contentacq</groupId>
    <artifactId>content-acq-copper-manifest-writer</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>content-acq-copper-manifest-writer</name>

    <properties>
        <java.version>11</java.version>
        <kotlin.version>1.5.21</kotlin.version>
        <start-class>org.cas.eo.contentacq.contentacqcoppermanifestwriter.Application</start-class>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>2.5.3</version>
        </dependency>

        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-reflect</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-kotlin</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- LOGGING -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.30</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.2.3</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>1.2.3</version>
        </dependency>
        <!-- end LOGGING-->

        <!-- DEPS from first try -->

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.cas.eo.contentacq.dbresources</groupId>
            <artifactId>dbresources-client</artifactId>
            <version>2.8.1</version>
        </dependency>

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
            <version>2.5.3</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-test</artifactId>
            <version>${kotlin.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <sourceDirectory>src/main/kotlin</sourceDirectory>
        <testSourceDirectory>src/test/kotlin</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <executions>
                    <!-- added from kotlinlang.org-->
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals> <goal>test-compile</goal> </goals>
                    </execution>
                    <!-- -->
                </executions>
                <configuration>
                    <args>
                        <arg>-Xjsr305=strict</arg>
                    </args>
                    <compilerPlugins>
                        <plugin>spring</plugin>
                    </compilerPlugins>
                    <jvmTarget>1.8</jvmTarget>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.jetbrains.kotlin</groupId>
                        <artifactId>kotlin-maven-allopen</artifactId>
                        <version>${kotlin.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

        </plugins>
    </build>

</project>

This is how I run it from Jenkins:
#!/bin/bash

cd /support/d63/copper/manifest_writer/dev

export SPRING_PROFILES_ACTIVE=dev

./run.sh

This is run.sh:
#!/bin/bash

JAVA_HOME=/usr2/jest/openjdk/java11

#This ensures that UTF-8 is always used, even for encoding file names.
export LC_ALL=en_US.UTF-8

cd /support/d63/copper/manifest_writer/dev

JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"
JAVA_OPTS="$JAVA_OPTS -Djava.security.egd=file:/dev/./urandom"

$JAVA_HOME/bin/java $JAVA_OPTS -jar content-acq-copper-manifest-writer-0.0.1-SNAPSHOT.jar $*

This is my start class:
package org.cas.eo.contentacq.contentacqcoppermanifestwriter

import org.cas.eo.contentacq.contentacqcoppermanifestwriter.props.ProcessProps
import org.springframework.boot.ApplicationArguments
import org.springframework.boot.ApplicationRunner
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.context.properties.ConfigurationPropertiesScan
import org.springframework.boot.runApplication

@SpringBootApplication
@ConfigurationPropertiesScan
class Application (
    private val controller: Controller,
    private val processProps: ProcessProps
): ApplicationRunner {

    fun main(args: Array<String>) {
        runApplication<Application>(*args)
    }

    override fun run(args: ApplicationArguments) {
        if (processProps.logOnly){
            controller.logManifests()
        } else {
            controller.writeManifests()
        }
    }
}

I run mvn clean package to get my jar.
Looking in the jar, this is the META-INF/MANIFEST.MF:
Manifest-Version: 1.0
Created-By: Maven Jar Plugin 3.2.0
Build-Jdk-Spec: 11
Implementation-Title: content-acq-copper-manifest-writer
Implementation-Version: 0.0.1-SNAPSHOT
Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: org.cas.eo.contentacq.contentacqcoppermanifestwriter.Applic
 ation
Spring-Boot-Version: 2.5.3
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Spring-Boot-Classpath-Index: BOOT-INF/classpath.idx
Spring-Boot-Layers-Index: BOOT-INF/layers.idx

Here are the rest of the jar contents:
Archive:  target/content-acq-copper-manifest-writer-0.0.1-SNAPSHOT.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2021-08-10 09:58   META-INF/
      518  2021-08-10 09:58   META-INF/MANIFEST.MF
        0  1980-02-01 00:00   org/
        0  1980-02-01 00:00   org/springframework/
        0  1980-02-01 00:00   org/springframework/boot/
        0  1980-02-01 00:00   org/springframework/boot/loader/
     5871  1980-02-01 00:00   org/springframework/boot/loader/ClassPathIndexFile.class
     6806  1980-02-01 00:00   org/springframework/boot/loader/ExecutableArchiveLauncher.class
     3966  1980-02-01 00:00   org/springframework/boot/loader/JarLauncher.class
     1483  1980-02-01 00:00   org/springframework/boot/loader/LaunchedURLClassLoader$DefinePackageCallType.class
     1535  1980-02-01 00:00   org/springframework/boot/loader/LaunchedURLClassLoader$UseFastConnectionExceptionsEnumeration.class
    11154  1980-02-01 00:00   org/springframework/boot/loader/LaunchedURLClassLoader.class
     5932  1980-02-01 00:00   org/springframework/boot/loader/Launcher.class
     1536  1980-02-01 00:00   org/springframework/boot/loader/MainMethodRunner.class
      266  1980-02-01 00:00   org/springframework/boot/loader/PropertiesLauncher$1.class
     1484  1980-02-01 00:00   org/springframework/boot/loader/PropertiesLauncher$ArchiveEntryFilter.class
     8128  1980-02-01 00:00   org/springframework/boot/loader/PropertiesLauncher$ClassPathArchives.class
     1953  1980-02-01 00:00   org/springframework/boot/loader/PropertiesLauncher$PrefixMatchingArchiveFilter.class
    18267  1980-02-01 00:00   org/springframework/boot/loader/PropertiesLauncher.class
     1750  1980-02-01 00:00   org/springframework/boot/loader/WarLauncher.class
        0  1980-02-01 00:00   org/springframework/boot/loader/archive/
      302  1980-02-01 00:00   org/springframework/boot/loader/archive/Archive$Entry.class
      511  1980-02-01 00:00   org/springframework/boot/loader/archive/Archive$EntryFilter.class
     4745  1980-02-01 00:00   org/springframework/boot/loader/archive/Archive.class
     6093  1980-02-01 00:00   org/springframework/boot/loader/archive/ExplodedArchive$AbstractIterator.class
     2180  1980-02-01 00:00   org/springframework/boot/loader/archive/ExplodedArchive$ArchiveIterator.class
     1857  1980-02-01 00:00   org/springframework/boot/loader/archive/ExplodedArchive$EntryIterator.class
     1269  1980-02-01 00:00   org/springframework/boot/loader/archive/ExplodedArchive$FileEntry.class
     2527  1980-02-01 00:00   org/springframework/boot/loader/archive/ExplodedArchive$SimpleJarFileArchive.class
     5346  1980-02-01 00:00   org/springframework/boot/loader/archive/ExplodedArchive.class
     2884  1980-02-01 00:00   org/springframework/boot/loader/archive/JarFileArchive$AbstractIterator.class
     1981  1980-02-01 00:00   org/springframework/boot/loader/archive/JarFileArchive$EntryIterator.class
     1081  1980-02-01 00:00   org/springframework/boot/loader/archive/JarFileArchive$JarFileEntry.class
     2528  1980-02-01 00:00   org/springframework/boot/loader/archive/JarFileArchive$NestedArchiveIterator.class
    10349  1980-02-01 00:00   org/springframework/boot/loader/archive/JarFileArchive.class
        0  1980-02-01 00:00   org/springframework/boot/loader/data/
      485  1980-02-01 00:00   org/springframework/boot/loader/data/RandomAccessData.class
      282  1980-02-01 00:00   org/springframework/boot/loader/data/RandomAccessDataFile$1.class
     2680  1980-02-01 00:00   org/springframework/boot/loader/data/RandomAccessDataFile$DataInputStream.class
     3259  1980-02-01 00:00   org/springframework/boot/loader/data/RandomAccessDataFile$FileAccess.class
     4015  1980-02-01 00:00   org/springframework/boot/loader/data/RandomAccessDataFile.class
        0  1980-02-01 00:00   org/springframework/boot/loader/jar/
     1438  1980-02-01 00:00   org/springframework/boot/loader/jar/AbstractJarFile$JarFileType.class
      878  1980-02-01 00:00   org/springframework/boot/loader/jar/AbstractJarFile.class
     4976  1980-02-01 00:00   org/springframework/boot/loader/jar/AsciiBytes.class
      616  1980-02-01 00:00   org/springframework/boot/loader/jar/Bytes.class
      295  1980-02-01 00:00   org/springframework/boot/loader/jar/CentralDirectoryEndRecord$1.class
     3401  1980-02-01 00:00   org/springframework/boot/loader/jar/CentralDirectoryEndRecord$Zip64End.class
     2004  1980-02-01 00:00   org/springframework/boot/loader/jar/CentralDirectoryEndRecord$Zip64Locator.class
     4682  1980-02-01 00:00   org/springframework/boot/loader/jar/CentralDirectoryEndRecord.class
     6223  1980-02-01 00:00   org/springframework/boot/loader/jar/CentralDirectoryFileHeader.class
     4620  1980-02-01 00:00   org/springframework/boot/loader/jar/CentralDirectoryParser.class
      540  1980-02-01 00:00   org/springframework/boot/loader/jar/CentralDirectoryVisitor.class
      345  1980-02-01 00:00   org/springframework/boot/loader/jar/FileHeader.class
    13649  1980-02-01 00:00   org/springframework/boot/loader/jar/Handler.class
     3885  1980-02-01 00:00   org/springframework/boot/loader/jar/JarEntry.class
     1458  1980-02-01 00:00   org/springframework/boot/loader/jar/JarEntryCertification.class
      299  1980-02-01 00:00   org/springframework/boot/loader/jar/JarEntryFilter.class
     2296  1980-02-01 00:00   org/springframework/boot/loader/jar/JarFile$1.class
     1299  1980-02-01 00:00   org/springframework/boot/loader/jar/JarFile$JarEntryEnumeration.class
    16312  1980-02-01 00:00   org/springframework/boot/loader/jar/JarFile.class
     1368  1980-02-01 00:00   org/springframework/boot/loader/jar/JarFileEntries$1.class
     2258  1980-02-01 00:00   org/springframework/boot/loader/jar/JarFileEntries$EntryIterator.class
    16395  1980-02-01 00:00   org/springframework/boot/loader/jar/JarFileEntries.class
     3512  1980-02-01 00:00   org/springframework/boot/loader/jar/JarFileWrapper.class
      702  1980-02-01 00:00   org/springframework/boot/loader/jar/JarURLConnection$1.class
     4302  1980-02-01 00:00   org/springframework/boot/loader/jar/JarURLConnection$JarEntryName.class
     9440  1980-02-01 00:00   org/springframework/boot/loader/jar/JarURLConnection.class
     3559  1980-02-01 00:00   org/springframework/boot/loader/jar/StringSequence.class
     1813  1980-02-01 00:00   org/springframework/boot/loader/jar/ZipInflaterInputStream.class
        0  1980-02-01 00:00   org/springframework/boot/loader/jarmode/
      293  1980-02-01 00:00   org/springframework/boot/loader/jarmode/JarMode.class
     2201  1980-02-01 00:00   org/springframework/boot/loader/jarmode/JarModeLauncher.class
     1292  1980-02-01 00:00   org/springframework/boot/loader/jarmode/TestJarMode.class
        0  1980-02-01 00:00   org/springframework/boot/loader/util/
     5174  1980-02-01 00:00   org/springframework/boot/loader/util/SystemPropertyUtils.class
        0  2021-08-10 09:58   BOOT-INF/
        0  2021-08-10 09:58   BOOT-INF/classes/
        0  2021-08-10 09:58   BOOT-INF/classes/org/
        0  2021-08-10 09:58   BOOT-INF/classes/org/cas/
        0  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/
        0  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/
        0  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/
        0  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/config/
        0  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/model/
        0  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/props/
        0  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/repo/
        0  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/service/
        0  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/utils/
        0  2021-08-10 09:58   META-INF/maven/
        0  2021-08-10 09:58   META-INF/maven/org.cas.eo.contentacq/
        0  2021-08-10 09:58   META-INF/maven/org.cas.eo.contentacq/content-acq-copper-manifest-writer/
     1807  2021-08-10 09:58   BOOT-INF/classes/application.yml
     3677  2021-08-10 09:58   BOOT-INF/classes/data.sql
        0  2021-08-10 09:58   BOOT-INF/classes/META-INF/
      111  2021-08-10 09:58   BOOT-INF/classes/META-INF/content-acq-copper-manifest-writer.kotlin_module
     3194  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/Application.class
     4058  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/config/DatabaseConfiguration.class
     7339  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/Controller.class
     4889  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/model/EndInfo.class
     5699  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/model/JournalArticle.class
     5418  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/model/JournalArticleMaterial.class
     4678  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/model/Manifest.class
     3096  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/model/ManifestKt.class
     7622  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/model/StartInfo.class
     3168  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/model/StartInfoKt.class
     3049  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/props/AltRunProps.class
     3217  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/props/ErrorProps.class
     3125  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/props/FileProps.class
     3246  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/props/ManifestProps.class
     6897  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/props/ProcessProps.class
     3044  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/props/ZipProps.class
    12394  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/repo/CopperRepository.class
     3740  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/service/JSONWriter.class
    11097  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/service/TANProcessor.class
     1185  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/utils/Logging$Companion.class
     6095  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/utils/Logging.class
     4767  2021-08-10 09:58   BOOT-INF/classes/org/cas/eo/contentacq/contentacqcoppermanifestwriter/utils/ManifestSerializer.class
     2204  2021-08-10 09:58   BOOT-INF/classes/schema.sql
     5662  2021-08-10 09:08   META-INF/maven/org.cas.eo.contentacq/content-acq-copper-manifest-writer/pom.xml
      102  2021-08-10 09:58   META-INF/maven/org.cas.eo.contentacq/content-acq-copper-manifest-writer/pom.properties
        0  2021-08-10 09:58   BOOT-INF/lib/
  1392390  2021-07-22 13:50   BOOT-INF/lib/spring-boot-2.5.3.jar
  1250332  2021-07-14 06:38   BOOT-INF/lib/spring-context-5.3.9.jar
   374939  2021-07-14 06:38   BOOT-INF/lib/spring-aop-5.3.9.jar
   282575  2021-07-14 06:38   BOOT-INF/lib/spring-expression-5.3.9.jar
    17762  2021-03-06 22:13   BOOT-INF/lib/log4j-to-slf4j-2.14.1.jar
   300365  2021-03-06 22:11   BOOT-INF/lib/log4j-api-2.14.1.jar
     4589  2021-07-20 13:55   BOOT-INF/lib/jul-to-slf4j-1.7.32.jar
    25058  2019-08-02 11:08   BOOT-INF/lib/jakarta.annotation-api-1.3.5.jar
  1458472  1980-02-01 00:00   BOOT-INF/lib/spring-core-5.3.9.jar
    23943  2021-07-14 06:37   BOOT-INF/lib/spring-jcl-5.3.9.jar
   326914  2021-02-22 05:55   BOOT-INF/lib/snakeyaml-1.28.jar
  2993765  1980-02-01 00:00   BOOT-INF/lib/kotlin-reflect-1.5.21.jar
  1497566  1980-02-01 00:00   BOOT-INF/lib/kotlin-stdlib-1.5.21.jar
    17536  2013-12-17 16:10   BOOT-INF/lib/annotations-13.0.jar
   197814  1980-02-01 00:00   BOOT-INF/lib/kotlin-stdlib-common-1.5.21.jar
   104930  2021-07-06 21:17   BOOT-INF/lib/jackson-module-kotlin-2.12.4.jar
  1516044  2021-07-06 20:01   BOOT-INF/lib/jackson-databind-2.12.4.jar
   365223  2021-07-06 19:51   BOOT-INF/lib/jackson-core-2.12.4.jar
    75705  2021-07-06 19:42   BOOT-INF/lib/jackson-annotations-2.12.4.jar
    41472  2019-12-16 22:03   BOOT-INF/lib/slf4j-api-1.7.30.jar
   290339  2017-03-31 20:20   BOOT-INF/lib/logback-classic-1.2.3.jar
   471901  2017-03-31 20:19   BOOT-INF/lib/logback-core-1.2.3.jar
   159222  2021-03-03 13:06   BOOT-INF/lib/HikariCP-4.0.3.jar
   417943  2021-07-14 06:39   BOOT-INF/lib/spring-jdbc-5.3.9.jar
   696496  2021-07-14 06:38   BOOT-INF/lib/spring-beans-5.3.9.jar
   326496  2021-07-14 06:39   BOOT-INF/lib/spring-tx-5.3.9.jar
  2303679  2019-10-14 09:19   BOOT-INF/lib/h2-1.4.200.jar
    31619  2018-05-29 07:59   BOOT-INF/lib/dbresources-client-2.8.1.jar
    13158  2018-05-29 07:50   BOOT-INF/lib/dbresources-lib-2.8.1.jar
   183147  2021-07-14 06:39   BOOT-INF/lib/spring-context-support-5.3.9.jar
     4523  2018-05-29 07:50   BOOT-INF/lib/dbresources-codec-2.8.1.jar
   353793  2020-01-22 15:10   BOOT-INF/lib/commons-codec-1.15.jar
   284220  2011-01-13 23:06   BOOT-INF/lib/commons-lang-2.6.jar
   575389  2008-04-11 15:37   BOOT-INF/lib/commons-collections-3.2.1.jar
   163151  2011-10-03 17:30   BOOT-INF/lib/commons-io-2.1.jar
   358048  2012-08-04 17:37   BOOT-INF/lib/commons-configuration-1.9.jar
    60686  2007-11-19 00:16   BOOT-INF/lib/commons-logging-1.1.1.jar
   159123  2010-12-14 20:30   BOOT-INF/lib/json-lib-2.4-jdk15.jar
   231320  2008-08-28 16:18   BOOT-INF/lib/commons-beanutils-1.8.0.jar
    86487  2008-08-08 11:10   BOOT-INF/lib/ezmorph-1.0.6.jar
  2152051  2010-08-14 12:20   BOOT-INF/lib/ojdbc6-11.2.0.2.0.jar
  1564883  2021-07-22 13:49   BOOT-INF/lib/spring-boot-autoconfigure-2.5.3.jar
    16125  1980-02-01 00:00   BOOT-INF/lib/kotlin-stdlib-jdk8-1.5.21.jar
    22993  1980-02-01 00:00   BOOT-INF/lib/kotlin-stdlib-jdk7-1.5.21.jar
    29278  1980-02-01 00:00   BOOT-INF/lib/spring-boot-jarmode-layertools-2.5.3.jar
     1909  2021-08-10 09:58   BOOT-INF/classpath.idx
      212  2021-08-10 09:58   BOOT-INF/layers.idx
---------                     -------
 23596713                     169 files

This is the error:
Exception in thread "main" java.lang.NullPointerException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)

Since it works in IntelliJ but not when running with java command, I assume I'm doing something wrong there.

A: (Just clutching at straws here…)
One thing occurs to me: your main() method is an instance method, which I've not seen and may be a problem.
In stand-alone programs, main() cannot be an instance method, as there's no instance to call it on yet.  I don't know whether the Spring loader makes special allowance for that situation, but in case it doesn't I'd suggest trying to move it either into a companion object:
class Application(/* … */): ApplicationRunner {

    companion object {
        fun main(args: Array<String>) {
            runApplication<Application>(*args)
        }
    }

    // …

Or out to a top-level function:
class Application(/* … */): ApplicationRunner {
    // …
}

fun main(args: Array<String>) {
    runApplication<Application>(*args)
}

In the latter case, you'd have to append Kt to the start-class tag (or wherever you specify the name of the class to run), since that's how the Kotlin/JVM compiler handles top-level functions.
It's a matter of style which one you prefer; a companion object is more tightly encapsulated, but a top-level function is slightly simpler and more concise.  (And since you don't generally have too many of them in any project, there's little danger of confusion or clashes.)


text:
Q: Issues Converting Plain Text Into Microsoft Word Bulleted Lists I'm a programmer.  I hate status reports.  I found a way to live with it.  While I am working in my IDE ( Visual Slickedit ) I keep a plain text file open in one of the file/buffer tabs.  As I finish things I just jot down a quick note into that file.  At the end of the week that becomes my weekly status report.  Example entries:
  The Datatables.net plugin runs very slowly in IE 8 with more than 2,000 records. I
  changed the way I did the server side code to process the data to make less work for the
  plugin to get decent performance for the IE 8 users.

  I made a class to wrap data from the new data collection objects into the legacy data
  holder objects.  This will let the new database code be backward compatible with the
  legacy code until we can replace it.

  I found the bug reported by Jane.  The software is fine.  The database we use for the
  test site has data that is corrupted in a way it wouldn't be for production site

At the end of the month I go back to each weekly *.txt file and paste all of the entries into a MS Word file for a monthly report.  I give the monthly report to a liason to the contracting company who has to compile everyone's monthly reports into a single MS Word 2007 document.   His problem, soon to be my problem, comes when he highlights my paragraphs like the ones above to put bullets in front of my paragraphs.
When he highlights my notes to put bullets in front of them with MS Word 2007, Word rearranges the text a bit and the new line chars/carriage returns stagger the text so the text is no longer in neat chunks.
This:
I found the bug reported by Jane.  The software is fine.  The database we use for the
test site has data that is corrupted in a way it wouldn't be for production site

Becomes This:
I found the bug reported by Jane.  The software is fine.  The database we use for
the
test site has data that is corrupted in a way it wouldn't be for production site

I tried turning word wrap on in my IDE for the text files I put my status notes in.  It just puts some kind of newline character in anyway.  Searching/Replacing those chars in the text files has the result of destroying the paragraphs.
Once my notes are pasted into  MS Word, Word automatically translates them into paragraph breaks.  Searching/Replacing them there has similar results.  Blank  lines separating the notes disappears.  One big mess.
What I would like is to be able to keep adding my status notes to a text file as I am now, but do something different when I paste the notes into MS Word such that my liason can select the text, hit the bulleting command and NOT have the staggered text as shown above.
Any ideas?
Thanks much in advance
Steve

A: You are using a single new line for wrapping and double new lines for paragraphs. Word recognises one or more new line as a new paragraph, which becomes a new bullet point. You need to introduce an extra step of manipulation before pasting into Word, where single new lines are removed.
If you can use regular expressions, it's a simple matter of replacing \r\n(?!\r\n) with nothing. This removes new lines (of the CR+LF variety) if they are not followed by another new line, therefore removing single line breaks.1
It has the side effect of reducing multiple new lines by one.2 You can do this with many advanced text editors; pretty much anything that supports Perl Compatible Regular Expressions (PCRE).
For example, in Notepad++:
Click for full size
Click for full size

To further tidy things up, you can replace multiple spaces with a single space, by replacing [ ]+ (one or more spaces) with  (a single space).

1\r means carriage return (CR), \n means line feed (LF). Windows uses CR+LF for new lines, Linux uses just LF. (?!something) denotes a negative lookahead in PCRE; i.e. it only matches if something does not appear. Also, the lookahead is not included in the match and therefore not replaced, it is only checked.
2(?<!\r\n)\r\n(?!\r\n) will not match/reduce if there's more than one line. It uses the negative lookbehind, (?<!something).

redpajama_set_name: RedPajamaStackExchange


text:
Q: Spring's @EntityListeners is throwing an exception when using @Postpersist I have a small test application for testing @EntityListeners functionality. When I run the application I get the following stacktrace
Exception in thread "main" org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction
    at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:526)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy67.save(Unknown Source)
    at com.example.hibernate_envers_test.HibernateEnversTestApplication.main(HibernateEnversTestApplication.java:32)
Caused by: javax.persistence.RollbackException: Error while committing the transaction
    at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:87)
    at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517)
    ... 17 more
Caused by: java.lang.NullPointerException
    at com.example.hibernate_envers_test.AccountListener.crudLogger(AccountListener.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.hibernate.jpa.event.internal.jpa.ListenerCallback.performCallback(ListenerCallback.java:35)
    at org.hibernate.jpa.event.internal.jpa.CallbackRegistryImpl.callback(CallbackRegistryImpl.java:94)
    at org.hibernate.jpa.event.internal.jpa.CallbackRegistryImpl.postCreate(CallbackRegistryImpl.java:63)
    at org.hibernate.jpa.event.internal.core.JpaPostInsertEventListener.onPostInsert(JpaPostInsertEventListener.java:38)
    at org.hibernate.action.internal.EntityInsertAction.postInsert(EntityInsertAction.java:164)
    at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:131)
    at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:582)
    at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:456)
    at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
    at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
    at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1282)
    at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:465)
    at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:2963)
    at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2339)
    at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:485)
    at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:147)
    at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
    at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:231)
    at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:65)
    at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:61)
    ... 18 more

As you can see it complains about not being able to commit a jpa transaction. Followed by a nullpointer exception whenever I try to use my accountHistoryRepo spring jpa repository interface. I have already checked whether the account pojo argument or the repository instance was null, it wasn't the case. When I replace @PostPersist with @PrePersist the TransactionSystemException no longer appears but I still have that mysterious nullpointer exception to deal with. Next to that I prefer to use PostPersist because I don't want to persist a history object when the actual object on which the history object is based wasn't persisted correctly. Can anyone help me? Below is the code of my test application:
AccountListener
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.example.hibernate_envers_test;

import com.example.pojo.Account;
import com.example.pojo.AccountHistory;
import javax.persistence.PostPersist;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 *
 * @author maurice
 */
@Component
public class AccountListener {

    @Autowired
    AccountHistoryRepo accountHistoryRepo;

    @PostPersist
    public void crudLogger(Account account){
        System.out.println("is account null?: " + account == null);
                System.out.println("is account null?: " + account.getJabberId());
        System.out.println("is accountHistoryrRepo null?: " + accountHistoryRepo);
        if (accountHistoryRepo.count()>=10) accountHistoryRepo.deleteOldestEntry();
        accountHistoryRepo.save(new AccountHistory(account));
    }
}

Account pojo
@Entity
@EntityListeners(AccountListener.class)
public class Account implements Serializable {

    @Id
    @GeneratedValue(generator = "ID_GENERATOR")
    private Long accountId;

    private String name;

    private boolean isEnabled;

    private boolean isSmartsuppEnabled;

    private String jabberId;

    private double budgetWarningPercentage;

    private boolean isSentBudgetWarning;

    private double budgetAmount;

    private int departmentLevel;

    private int contactId;

    public Long getAccountId() {
        return accountId;
    }

    public Account setAccountId(Long accountId) {
        this.accountId = accountId;
        return this;
    }

    public String getName() {
        return name;
    }

    public Account setName(String name) {
        this.name = name;
        return this;
    }

    public boolean isIsEnabled() {
        return isEnabled;
    }

    public Account setIsEnabled(boolean isEnabled) {
        this.isEnabled = isEnabled;
        return this;
    }

    public boolean isIsSmartsuppEnabled() {
        return isSmartsuppEnabled;
    }

    public Account setIsSmartsuppEnabled(boolean isSmartsuppEnabled) {
        this.isSmartsuppEnabled = isSmartsuppEnabled;
        return this;
    }

    public String getJabberId() {
        return jabberId;
    }

    public Account setJabberId(String jabberId) {
        this.jabberId = jabberId;
        return this;
    }

    public double getBudgetWarningPercentage() {
        return budgetWarningPercentage;
    }

    public Account setBudgetWarningPercentage(double budgetWarningPercentage) {
        this.budgetWarningPercentage = budgetWarningPercentage;
        return this;
    }

    public boolean isIsSentBudgetWarning() {
        return isSentBudgetWarning;
    }

    public Account setIsSentBudgetWarning(boolean isSentBudgetWarning) {
        this.isSentBudgetWarning = isSentBudgetWarning;
        return this;
    }

    public double getBudgetAmount() {
        return budgetAmount;
    }

accounthistory pojo
@Entity(name = "account_history")
public class AccountHistory implements Serializable {
    @Id
    @GeneratedValue(generator = "ID_GENERATOR")
    private Long accountHistoryId;

    private Long accountId;

    private String name;

    private boolean isEnabled;

    private boolean isSmartsuppEnabled;

    private String jabberId;

    private double budgetWarningPercentage;

    private boolean isSentBudgetWarning;

    private double budgetAmount;

    private int departmentLevel;

    private int contactId;

    public AccountHistory(){}

    public AccountHistory(Account account){
        this.accountId = account.getAccountId();
        this.name = account.getName();
        this.isEnabled = account.isIsEnabled();
        this.isSmartsuppEnabled  = account.isIsSmartsuppEnabled();
        this.jabberId = account.getJabberId();
        this.budgetWarningPercentage = account.getBudgetWarningPercentage();
        this.isSentBudgetWarning = account.isIsSentBudgetWarning();
        this.budgetAmount = account.getBudgetAmount();
        this.departmentLevel = account.getDepartmentLevel();
        this.contactId = account.getContactId();
    }

    public Long getAccountId() {
        return accountId;
    }

    public AccountHistory setAccountId(Long accountId) {
        this.accountId = accountId;
        return this;
    }

    public String getName() {
        return name;
    }

    public AccountHistory setName(String name) {
        this.name = name;
        return this;
    }

    public boolean isIsEnabled() {
        return isEnabled;
    }

    public AccountHistory setIsEnabled(boolean isEnabled) {
        this.isEnabled = isEnabled;
        return this;
    }

    public boolean isIsSmartsuppEnabled() {
        return isSmartsuppEnabled;
    }

    public AccountHistory setIsSmartsuppEnabled(boolean isSmartsuppEnabled) {
        this.isSmartsuppEnabled = isSmartsuppEnabled;
        return this;
    }

    public String getJabberId() {
        return jabberId;
    }

    public AccountHistory setJabberId(String jabberId) {
        this.jabberId = jabberId;
        return this;
    }

    public double getBudgetWarningPercentage() {
        return budgetWarningPercentage;
    }

    public AccountHistory setBudgetWarningPercentage(double budgetWarningPercentage) {
        this.budgetWarningPercentage = budgetWarningPercentage;
        return this;
    }

    public boolean isIsSentBudgetWarning() {
        return isSentBudgetWarning;
    }

    public AccountHistory setIsSentBudgetWarning(boolean isSentBudgetWarning) {
        this.isSentBudgetWarning = isSentBudgetWarning;
        return this;
    }

    public double getBudgetAmount() {
        return budgetAmount;
    }

    public AccountHistory setBudgetAmount(double budgetAmount) {
        this.budgetAmount = budgetAmount;
        return this;
    }

    public int getDepartmentLevel() {
        return departmentLevel;
    }

    public AccountHistory setDepartmentLevel(int departmentLevel) {
        this.departmentLevel = departmentLevel;
        return this;
    }

    public int getContactId() {
        return contactId;
    }

    public AccountHistory setContactId(int contactId) {
        this.contactId = contactId;
        return this;
    }
}

    public Account setBudgetAmount(double budgetAmount) {
        this.budgetAmount = budgetAmount;
        return this;
    }

    public int getDepartmentLevel() {
        return departmentLevel;
    }

    public Account setDepartmentLevel(int departmentLevel) {
        this.departmentLevel = departmentLevel;
        return this;
    }

    public int getContactId() {
        return contactId;
    }

    public Account setContactId(int contactId) {
        this.contactId = contactId;
        return this;
    }
}

AccountHistoryRepo
@Repository
public interface AccountHistoryRepo extends JpaRepository<AccountHistory,Long> {
    @Query("DELETE FROM account_history p WHERE p.accountHistoryId = (SELECT MIN(p.accountHistoryId) FROM account_history p)")
    public void deleteOldestEntry();
}

AccountRepo
@Repository
public interface AccountRepository extends JpaRepository<Account,Long> {

}

main class
@SpringBootApplication
public class HibernateEnversTestApplication implements ApplicationContextAware  {

    private static ApplicationContext ac;

//    @Autowired
//    AccountRepository accountRepo;
    public static void main(String[] args) {
        SpringApplication.run(HibernateEnversTestApplication.class, args);
                AccountRepository accountRepo = ac.getBean(AccountRepository.class);
                //Account account = accountRepo.findOne(1003L);
                Account account = new Account();
                account.setBudgetAmount(6666.4)
                        .setBudgetWarningPercentage(66666.2)
                        .setContactId(3333)
                        .setDepartmentLevel(44444)
                        .setIsEnabled(true)
                        .setIsSentBudgetWarning(false)
                        .setIsSmartsuppEnabled(true)
                        .setJabberId("en dit is aanpassing 4")
                        .setName("henk");
                accountRepo.save(account);
    }

            @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.ac = applicationContext;
    }
}

root config
@Configuration
@PropertySources(value = {@PropertySource("classpath:application.properties")})
@ComponentScan//(basePackages={"repository"})
@EnableJpaRepositories//(basePackages={"repository"})
@EnableTransactionManagement
public class RootConfig {

  @Value("${spring.datasource.url}")
  private String dataBaseUrl;
  @Value("${spring.datasource.driver}")
  private String driver;
  @Value("${spring.datasource.username}")
  private String userName;
  @Value("${spring.datasource.password}")
  private String password;
  @Value("${spring.datasource.strategy}")
  private String strategy;

@Bean(destroyMethod = "close")
public DataSource seedDataSource(){
    HikariConfig hikariConfig = new HikariConfig();
    hikariConfig.setDriverClassName(driver);
    hikariConfig.setJdbcUrl(dataBaseUrl);
    hikariConfig.setUsername(userName);
    hikariConfig.setPassword(password);

    hikariConfig.setMaximumPoolSize(5);
    hikariConfig.setConnectionTestQuery("SELECT 1");
    hikariConfig.setPoolName("springHikariCP");

    hikariConfig.addDataSourceProperty("dataSource.cachePrepStmts", "true");
    hikariConfig.addDataSourceProperty("dataSource.prepStmtCacheSize", "250");
    hikariConfig.addDataSourceProperty("dataSource.prepStmtCacheSqlLimit", "2048");
    hikariConfig.addDataSourceProperty("dataSource.useServerPrepStmts", "true");

    HikariDataSource dataSource = new HikariDataSource(hikariConfig);

    return dataSource;
}

  @Bean
  JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(entityManagerFactory);
    return transactionManager;
  }

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
                                                                JpaVendorAdapter jpaVendorAdapter){
  LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
  Properties props = new Properties();
  props.put("org.hibernate.envers.audit_strategy","org.hibernate.envers.strategy.ValidityAuditStrategy");
  props.put("org.hibernate.envers.audit_strategy_validity_store_revend_timestamp", "true");
  props.put("org.hibernate.envers.track_entities_changed_in_revision","true");
  props.put("org.hibernate.envers.global_with_modified_flag","true");
  props.put("org.hibernate.envers.store_data_at_delete", "true");
  props.put("hibernate.listeners.envers.autoRegister", "true");

  entityManagerFactory.setDataSource(dataSource);
  entityManagerFactory.setJpaVendorAdapter(jpaVendorAdapter);
  entityManagerFactory.setPackagesToScan("com.example.pojo");
  entityManagerFactory.setJpaProperties(props);
  return entityManagerFactory;
}

@Bean
public JpaVendorAdapter jpaVendorAdapter(){
    HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    adapter.setDatabase(Database.MYSQL);
    adapter.setShowSql(false);
    adapter.setGenerateDdl(true);
    adapter.setDatabasePlatform("org.hibernate.dialect.MySQLDialect");
    return adapter;
}

}

A: Even though you made the entity listener a @Component, what JPA uses is actually just an instance of the class and is not a spring managed bean. That's why you're getting a NullPointerException. The accountHistoryRepo will always be null.


text:
Q: How do LoRa end-devices configure their upstream and downstream communication? I'm in the process of building a LoRa end device, and am also designing protocol. I plan on using the channels specified in the AUS915 ISM Band as outlined in the LoRaWAN regional parameters (though i'm not using LoRaWAN):

*

*Upstream Channels 0 to 63,125KHz, DR0 to DR5, 915.2MHz-927.8MHz, 200kHz inc.

*Upstream Channels 64 to 71,500KHz, DR6, 915.9MHz-927.1MHz, 1.6MHz inc.

*Downstream Channels 0 to 7,500KHz, DR8 to DR13, 923.3MHz-927.5MHz, 600KHz inc.

I'm confused about the typical operation of an end device. Does this channel plan suggest that to use an end device effectively and this channel plan, I will need to send data from it on any of the 72 upstream channels, but have to switch configuration entirely to then recieve packets in one of the 8 downstream frequencies?

EDIT:
From the Radiocommunications (Low Interference Potential Devices) Class Licence 2015:

*

*All transmitters, 915–928MHz, 3 mW max EIRP

*Frequency hopping transmitters, 915–928MHz, 1 W max EIRP, A minimum of 20 hopping frequencies must be used

*Digital modulation transmitters, 915–928MHz, 1 W max EIRP, The radiated peak power spectral density in any 3 kHz must not exceed 25 mW per 3 kHz

A: I'm not sure about AU, but in the US, typically the gateway will listen on a set of 8 consecutive upstream channels called a sub-band. The end device will try transmitting join requests on random channels across all sub-bands until it gets a response. The device will then frequency-hop within that channel's sub-band, changing frequency after every packet.
Join responses, like all downstream packets, are sent on one of the downstream channels. Usually it's channel associated with the upstream sub-band, i.e. downstream channel 0 goes with the first 8 upstream channels, downstream channel 1 goes with the next 8 upstream channels, and so on.
Your end device's transceiver will need to transmit on the upstream channels and receive on the downstream channels. LoRaWAN inverts the signal polarity for downstream channels, so the end devices normally don't receive each other's packets.


text:
Q: How to add JavaScript code into existing iFrame using jQuery? I want to add a JavaScript snippet into an existing iFrame in the page using jQuery. I have the following code...
Code:
content = "";

$('#iframe_id').contents().find('body').append(content);

But somehow this is not working. I checked some of the existing/related answers, and it seems jQuery does not quite recognize the script tags as...script tags. The iFrame is in the same domain/same port/same host, so there is no issue about cross-site scripting etc. How can I fix this?

A: function putScriptInIframes(script, scriptId) {

   var $iframes = $('iframe');
   $iframes.each(function () {
        var thisDoc = this.contentWindow.document;
        if ( ! thisDoc.getElementById(scriptID)) {
            var scriptObj = thisDoc.createElement("script");
            scriptObj.type = "text/javascript";
            scriptObj.id = scriptId;
            scriptObj.innerHTML = script;
            thisDoc.body.appendChild(scriptObj);
        }
    });
}

This was the simplest way I could make it work.

A: var script = "alert('hello world');";
$('#iframe').contents().find('body').append($(') and it closes the script tag prematurely.
The solution is to escape the / in "<\/script>". This works because strings in JavaScript, (and some other languages), any invalid escape sequences are just ignored, so "\l" is treated as "l", and "\/" is treated as "/". The HTML parser, however, doesn't use a backslash to escape them so it doesn't get confused (credits to https://stackoverflow.com/users/405681/keaukraine).
var scriptTag = " in their code (jsfiddle):
var scriptTag = "

EDIT: So I played with this a bit more and here is what I came up with.
HTML

JS
$("#frame").attr(
   "src", "data:text/html;charset=utf-8," +
   "" +
   "" +
   "
Test</test>" +
   "


text:
Q: How to add numbers in Text file with Strings import csv

csv_file = 'Annual Budget.csv'
txt_file = 'annual_budget.txt'
with open(txt_file, 'w') as my_output_file:
with open(csv_file, 'r') as my_input_file:
    reader = csv.reader(my_input_file)
    for row in reader:
        my_output_file.write(" ".join(row)+'\n')
        data = []
with open(r'annual_budget.txt', 'r') as f:
 reader = csv.reader(f)
 header = next(reader)
 for line in reader:
     rowdata = map(float, line)
     data.extend(rowdata)
 print(sum(data)/len(data))

Trying to add the numbers in a text file with strings but error is continually thrown.
Output:
data.extend(rowdata)

ValueError: could not convert string to float:

Data Set:  [1]: https://i.stack.imgur.com/xON30.png

A: TLDR: You're treating space delimited text as csv which is not parsing correctly by the csv module.
At the time I worked this problem out for you, you had not provided origional csv data, so for this problem I assumed your csv file contained the following data, based on your screenshot of the txt file.
Annual Budget,Q2,Q4
100,450,20
600,765,50
500,380,79
800,480,455
1100,65,4320

Now, about the code.
You're defining data = [] in a place where it is not only
not used, but also causing it to be reset to an empty
list with every loop through the file you're converting.
If we add a print statement directly under it we get this for output:
showing added print statement:
with open(txt_file, 'w') as my_output_file:
     with open(csv_file, 'r') as my_input_file:
         reader = csv.reader(my_input_file)
         for row in reader:
             my_output_file.write(" ".join(row)+'\n')
             data = []
             print(data)

Output:
[]
[]
[]
[]
[]
[]

Moving data = [] to the top of the file prevents that.
Now with the second with statement and loops you're treating the txt file you just created as a csv file. csv data is comma delimited not space delimited. The csv reader isn't parsing the row correctly. if we add a print loop to check what is coming out of the map function we can see it's not doing what you're expecting it to, which is convert it to a list of floats.
Relevent code:
for line in reader:
    rowdata = map(float, line)
    for element in rowdata:
        print(element)

output:
Traceback (most recent call last):
  File "test.py", line 17, in <module>
    for element in rowdata:
ValueError: could not convert string to float: '100 450 20'

There are multiple ways to solve the problem, but I think the best is to simply skip the whole first loop where you convert it to a space delimited file. Doing so we just depend on the csv module to do it's job.
example code:
import csv

data = []

with open('Annual Budget.csv', 'r') as f:
    reader = csv.reader(f) # Gets the reader
    header = next(reader) # advance the reader past the header.
    for line in reader:
        rowdata = map(float, line)

        for element in rowdata:
            print(element)

Output:
100.0
450.0
20.0
600.0
765.0
50.0
500.0
380.0
79.0
800.0
480.0
455.0
1100.0
65.0
4320.0

Now we'll add your last couple lines of code back in and remove the test code:
import csv

data = []

with open('Annual Budget.csv', 'r') as f:
    reader = csv.reader(f) # Gets the reader
    header = next(reader) # advance the reader past the header.
    for line in reader:
        rowdata = map(float, line)
        data.extend(rowdata)
    print(sum(data)/len(data))

Which now outputs:
677.6


text:
Q: Prolog SWI List creation Knowledge Representation:
student('John','f214','A').
student('John','f222','B').
student('John','f213','C').
student('John','f343','D').

subject(f214,3).
subject(f222,3).
subject(f213,3).
subject(f343,3).

From the given knowledge representation in Prolog SWI How can I create list of courses [f214,f222,f213,f343] and list of corresponding grades ['A','B','C','D']

A: You can use findall/3:
?- findall(Course, subject(Course, _), Courses).
Courses = [f214, f222, f213, f343].

?- findall(Grade, student(_,Grade,_), Grades).
Grades = [f214, f222, f213, f343].

?- findall(course_grade(Course, Grade), (subject(Course,_), student(_,Course,Grade)), CoursesGrades).
CoursesGrades = [course_grade(f214, 'A'), course_grade(f222, 'B'), course_grade(f213, 'C'), course_grade(f343, 'D')].


text:
Q: A prime number divides only the numerator I need to prove that there is a prime number $q$ which divides the numerator of $\frac{x^{\ell e}-1}{(x^{\ell}-1)(x^{e}-1)}$ and doesn't divide the denominator. Here, $\ell,e,x$ are integers, and $x$ is of the form $p_1^{p_2^{\ell-1}}\cdot p_2^{p_1^{e-1}}$, where $p_1,p_2$ are primes distinct from $q$, and $\ell =p_1$, $e=p_2$.

*

*Forgot something important: $\ell e>\ell+e$.

Attempt:
I have tried using the next sentence to make it easier for me:
$$(x^{\ell}-1,x^{e}-1)=x^{(\ell,e)}-1$$ Since $(\ell,e)=1,$ we get: $(x^{\ell}-1,x^{e}-1)=x^{(\ell,e)}-1=x-1$.
To prove that there is a prime $q$ divides only the numerator, we shall check whether the number $\frac{x^{\ell e}-1}{(x^{\ell}-1)(x^{e}-1)}$ is integer, and after division of the numerator by the denominator, there is $q$ in the factorization.
Without any success from here.

A: We can write:
$$\frac{N=(x^l)^e-1}{D=(x^l-1)(x^e-1)}=\frac{(x^l)^{e-1}+(x^l)^{e-2}+\cdot \cdot \cdot +1}{x^e-1}$$
If $e=2k$ is even then:
$x^l+1|(x^l)^{e-1}+(x^l)^{e-2}+\cdot \cdot \cdot +1$
Therefore:
$x^l+1|N$
Also we have:
$D=x^e-1=(x^k-1)(x^k+1)$
If $l\neq k=\frac e2$ then $x^l+1$ divides N but does not divide D.So $x^l+1$ must be primes .For example for $l=2$ and  $x=2$ gives $q=5$ so if e=6 , for instance, we get:
$D=(2^2-1)(2^6-1)=189$
$N=2^{12}-1=4095$.
The fraction is symmetric for and l and e so we may change e with l in above argument; the condition is:
$L\neq \frac e2$
Or:
$e\neq \frac l2$
That is one of l or e must be even.
Update:
Suppose e and l are odd, then it is possible to have a prime satisfying the condition for example for x=2, l=3, e=5 we get:
$\frac ND=\frac{2^{15}-1}{(2^3-1)(2^5-1)}=\frac{151}{7\cdot 31}$
So prime we are looking for is $151$.
Also for certain values of x, e and l, the numerator my be divisible by denominator. The condition must be discussed in separate question. For example for x=2,l=2, e=5 we get:
$\frac ND=31$
So 31 divides numerator.
Or with x=3, l=2 and e=5 we get:
$\frac ND=4 \times 61$
That means prime 61 only divides the numerator.


text:
Q: How do I retrieve the Twilio fax PDF and attach it to an email using Node.js inside a Twilio function? Is there any way I can use Twilio's serverless options to retrieve a PDF that was faxed earlier and attach it to an email?
I've learned how to do this in PHP in WordPress on my own personal web server by looking at examples. Here's a snippet of WordPress PHP code that retrieves a PDF that was faxed using Twilio and then sends an email with the PDF as an attachment:
<?php
  $mediaurl = $_GET["MediaUrl"];
  $path = '/some/path/on/your/web/server/where/to/save/the/PDF';
  $attachment = $filename = $path . $_GET["FaxSid"] . '.pdf';
  require_once('wp-load.php');
  $response = wp_remote_get( $mediaurl, array( 'timeout' => '300', 'stream' => true, 'filename' => $filename ) );
  wp_mail( 'somebody@somewhere.com', 'You have a fax', 'See attached PDF', 'From: <someone@someplace.com>', $attachment );
?>

In case someone is learning about these things, I have the above code saved in a twilio-fax-receive.php file on my web server. And to run it every time a fax comes in, I have a TwiML Bin set up on Twilio -- I called it receive-fax -- with this code in it:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Receive action="https://www.somewhere.com/twilio-fax-receive.php" method="GET"/>
</Response>

Then, on the "Configure" page for the fax number that receives faxes, I selected TwiML where it says "A FAX COMES IN" and then selected my receive-fax TwiML Bin.
But back to my issue.
Can I replicate that using Node.js inside a Twilio function? Or some other way using only Twilio, without my own web server? Is there a way to get the contents of the PDF, encode it with base64 and attach to an email using SendGrid or some other service on the fly in Node.js?
Does anybody have a working example? I've tried a lot of things I found on the Web that involved request.get and got.stream and pipe and Buffer and fs, but to no avail...
I am not a developer, and I think I am in way over my head. Your help would be very much appreciated.

A: Twilio developer evangelist here.
Yes, you can replicate this using Node.js in a Twilio Function. Here's how using SendGrid to send the email:

*

*Add request to your Runtime dependencies. I used version 2.88.0

*Add the following environment variables to your Functions config:

*

*TO_EMAIL_ADDRESS: the email address you want to deliver faxes to.

*FROM_EMAIL_ADDRESS: the email address you want to receive faxes from.

*SENDGRID_API_KEY: Your SendGrid API key

*Save the config section

*Create a new function and add the following code:
const request = require('request');

exports.handler = function(context, event, callback) {
  const faxUrl = event.MediaUrl;

  const email = {
    personalizations: [{ to: [{ email: context.TO_EMAIL_ADDRESS }] }],
    from: { email: context.FROM_EMAIL_ADDRESS },
    subject: `New fax from ${event.From}`,
    content: [
      {
        type: 'text/plain',
        value: 'Your fax is attached.'
      }
    ],
    attachments: []
  };

  request.get({ uri: faxUrl, encoding: null }, (error, response, body) => {
    if (!error && response.statusCode == 200) {
      email.attachments.push({
        content: body.toString('base64'),
        filename: `${event.FaxSid}.pdf`,
        type: response.headers['content-type']
      });
    }
    request.post(
      {
        uri: 'https://api.sendgrid.com/v3/mail/send',
        body: email,
        auth: {
          bearer: context.SENDGRID_API_KEY
        },
        json: true
      },
      (error, response, body) => {
        if (error) {
          return callback(error);
        } else {
          if (response.statusCode === 202) {
            return callback(null, new Twilio.twiml.VoiceResponse());
          } else {
            return callback(body);
          }
        }
      }
    );
  });
};

*Give the Function a path and save it.

*Add the path as the action attribute to your <Receive> element in your TwiML bin.

*Send in the fax and watch it arrive in your inbox.

Let me know if this works for you, I'll write up how the code works in more detail when I get the time.

A: There's another easy way to do it if you're using Gmail.
create a google apps script which sends an email to wherever you want using MailApp.
Use the "MediaUrl" parameter to send it as an attachment.
function doGet(e) {
        var emailAddress = "EMAIL_ADDR_TO_SEND_TO";
        var from = e.parameter.From;
        var subject = "New Fax from  " + from;
        var body = "New fax attached";
        var fileUrl = e.parameter.MediaUrl;
        var file = UrlFetchApp.fetch(fileUrl);

          MailApp.sendEmail(emailAddress, subject, body, {
        attachments: [file.getAs(MimeType.PDF)]
      });
      }

Deploy it as a webapp that's public.
Copy Url and insert it in the "action" attribute of your TwiML <Receive/> tag.
make sure you set "method" to "GET"
TwiML should look like this
<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Receive action="YOUR_GOOGLE_WEBAPP_URL" method="GET"/>
</Response>

Then configure you're Twilio number to that TwiML file


text:
Q: can i rebase old commits? I have just started using git. Rebase is great stuff.  I should have used it in a specific earlier case.
is there a perfectly acceptable way to rebase old commits for the sake of clear commits?

A: In general, if you've shared a commit with someone else, don't rebase it.
If you haven't shared a commit with anyone else, you can do whatever you want to it.
See the "RECOVERING FROM UPSTREAM REBASE" section of the git-rebase manpage for more info.

A: You should positively only do this for commits that have not been pushed upstream. That said, I find it easiest to use git rebase -i <commit> where <commit> is the id of a commit that is at least as old as the newest one you do not want to mess with. When your editor pops up, it will contain instructions about how to squash and/or delete commits.


text:
Q: PHP - How to change font size of HTML table? I'm generating table in a foreach loop
echo "
";

    echo "".$monthName."	";
    echo "".$id."	";
    echo "".$total."	"

echo "
";

I need to increase font size of the table, but i'm not sure how. Does the html table has attribute to set font size or I should use CSS ?

A: Just use font style css in style attribute :
echo "
";

    echo "".$monthName."	";
    echo "".$id."	";
    echo "".$total."	"

echo "
";

A: use the html styling on the echoed elements. For example echo '
';

A: You need to define font size in one variable and then use in inline as below code:
foreach{
    $fontsize = 'font-size: '.((isset(FONT_SIZE_IN_FOREACH))?FONT_SIZE_IN_FOREACH:12);
echo "
";

    echo "".$monthName."	";
    echo "".$id."	";
    echo "".$total."	"

echo "
";
}

A: You can add class to the table and write css for that class.
HTML:

CSS:
.fontsize {
   font-size:16px;
 }


text:
Q: VBA Excel find a file (partial file name) in a set of folders Good Morning/Afternoon/Evening,
I would like some syntax help for the following code or point me in the direction of something that does it better as there is a few things that are not quite right.
I originally had a list files in a folder macro and I've adapted that to try and do what I want.
So here goes, I have a list of stem file names (strDesignDocs) and I have a top folder of where I will find a version of these files (combobox21.value).
I feed the top folder path and the part file name into the ListMyFiles function hoping that just for test purposes it will give me the message of the full file name that has been found and also the full folder path as well. it does print the message within the function but would like it to pass it back to the calling function to eventually do something else with.
With the code below:

*

*it doesn't seem to exit the function once the file has been found, (it just seems to move to the next folder still looking for the same file without banging out of the entire function)

*It doesn't return the value back to the calling function, probably because it carries on past the exit function that I still can't fix.

*It never seems to return to the calling function but still tries to process all the files, so can only assume that it does.

TYIA
Andy
Dim iRow
Dim Counter
Dim myFile As Scripting.File
Sub ListFiles()
    Dim WS1, WS2 As Worksheet
    Dim strDesignDocs As Variant
    On Error Resume Next

    Set WS1 = Sheets("Data")
    Set WS2 = Sheets("Clean_Up")

    With WS1
        Set strDesignDocs = .Range(.Cells(15, 1), .Cells(27, 1))
    End With

    For Each cell In strDesignDocs
        strReturnValue = ListMyFiles(ComboBox21.Value, True, cell.Value)
        Debug.Print strReturnValue
    Next
End Sub

Function ListMyFiles(mySourcePath, IncludeSubfolders, sFileName)
    Dim MyObject As Scripting.FileSystemObject

    On Error Resume Next
    Set MyObject = New Scripting.FileSystemObject
    Set mySource = MyObject.GetFolder(mySourcePath)

    For Each myFile In mySource.Files
        If InStr(1, myFile.Name, sFileName) <> 0 Then
            strReport = myFile.Name & " in " & myFile.Path
            ListMyFiles = strReport
            'Debug.Print strReport
            Exit Function
        End If

    Next
    If IncludeSubfolders Then
        For Each mySubFolder In mySource.SubFolders
            Call ListMyFiles(mySubFolder.Path, True, sFileName)
        Next
    End If
End Function


text:
Q: Inflation Issue in Recycler view I am using a recycler view in android to show the list of data.I am using link preview also in the view holder class. but my recycler view is not showing any data the page is null.
and its is showing error -
android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class <unknown>

I have tried many things but not getting any output from there.I have checked my xml file code. which is correct. I have checked the code also but not getting the issue anywhere.
custom row items -
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_marginRight="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="10dp"
    android:layout_marginBottom="10dp"
    app:cardCornerRadius="10dp">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="15dp"
        android:paddingBottom="15dp">
    <LinearLayout
        android:layout_marginTop="3dp"
        android:layout_marginBottom="3dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingTop="5dp"
        android:paddingBottom="5dp"
        android:paddingRight="5dp"
        android:paddingLeft="5dp"
        android:baselineAligned="false">
        <LinearLayout
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical">
        <com.pkmmte.view.CircularImageView
            android:id="@+id/user_profile_image_view"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:gravity="center_vertical"
            android:src="@drawable/user_icon"
            android:adjustViewBounds="true"/>
        </LinearLayout>

        <LinearLayout
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:layout_weight="4"
            android:orientation="vertical"
            android:layout_marginStart="15dp">
            <TextView
                android:id="@+id/post_user_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="User Name"
                android:textStyle="bold"
                android:textColor="#000"
                android:padding="3dp"
                android:textSize="15sp"/>
            <TextView
                android:id="@+id/post_time"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Date"
                android:padding="3dp"
                android:textSize="12sp"/>
    </LinearLayout>
    </LinearLayout>
    <TextView
        android:id="@+id/post_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="User Text"
        android:padding="2dp"
        android:layout_marginEnd="10dp"
        android:layout_marginBottom="10dp"
        android:layout_marginStart="20dp"
        android:textColor="#000"
        android:textSize="13sp"
        android:visibility="gone"/>

    <FrameLayout
        android:id="@+id/media_frame_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="gone"
        >
        <com.google.android.youtube.player.YouTubeThumbnailView
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:src="@drawable/jellyfish"
            android:scaleType="fitXY"
            android:visibility="gone"/>
        <com.google.android.youtube.player.YouTubePlayerView
            android:id="@+id/media_youtube_player_view"
            android:visibility="gone"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            >
        </com.google.android.youtube.player.YouTubePlayerView>
        <ImageView
            android:id="@+id/media_video_image_view"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:scaleType="fitXY"
            android:visibility="gone"
           />

        <VideoView
            android:id="@+id/media_video_view"
            android:layout_height="200dp"
            android:layout_width="match_parent"
            android:layout_gravity="center_horizontal"
            android:visibility="gone"

            />
        <ImageView
            android:id="@+id/media_image_view"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:scaleType="fitXY"
            android:visibility="gone"
            />
        <ImageView
            android:id="@+id/video_play_button"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_gravity="center_horizontal|center_vertical"
            android:src="@drawable/video_play_button_black"
            android:visibility="gone"
            android:clickable="true"
            android:focusable="true" />
    </FrameLayout>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/link_textView"
        android:padding="10dp"
        android:textSize="15sp"
        android:background="#cdc9c9"
        android:clickable="true"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:textColor="#000"
        android:visibility="gone"/>
    <android.support.v7.widget.CardView
        android:id="@+id/twitter_link_card_view"
        android:layout_height="150dp"
        android:layout_width="match_parent"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:visibility="gone"
        >
        <com.freesoulapps.preview.android.Preview
            android:id="@+id/link_preview"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:padding="10dp"
            android:gravity="center_vertical"
            android:clickable="true"
            android:focusable="true">

        </com.freesoulapps.preview.android.Preview>
    </android.support.v7.widget.CardView>
    <View
        android:layout_width="fill_parent"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="5dp"
        android:layout_height="1dp"
        android:background="#CFD8DC" />

    <LinearLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:layout_marginTop="5dp"
        android:orientation="horizontal"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp">
        <ImageView
            android:id="@+id/post_like_image_view"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:clickable="true"
            android:src="@drawable/like_heart_icon"
            android:padding="2dp"
            android:focusable="true" />
        <ImageView
            android:id = "@+id/post_liked_image_view"
            android:layout_width="0dp"
            android:clickable="true"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/like_blue_image_icon"
            android:padding="2dp"
            android:visibility="gone"
            android:focusable="true" />
        <ImageView
            android:id="@+id/post_comment_image_view"
            android:layout_width="0dp"
            android:clickable="true"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/comment_icon"
            android:padding="2dp"
            android:focusable="true" />
        <ImageView
            android:id="@+id/post_sharing_imageView"
            android:clickable="true"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/share_icon"
            android:padding="2dp"
            android:focusable="true" />
    </LinearLayout>
        <LinearLayout
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:orientation="vertical">
            <EditText
                android:id="@+id/comment_box"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/edit_text_style1"
                android:padding="5dp"
                android:layout_margin="10dp"
                android:visibility="gone"
                android:hint="Type your Comment"
                />

        </LinearLayout>

</LinearLayout>
</android.support.v7.widget.CardView>

code for my adapter class -
public class AdapterRecyclerView extends RecyclerView.Adapter<MyViewHolder> implements  Preview.PreviewListener {
    private List<AllDataModel> allDataArrayList;
    private Context context;
    private int resource;
    Preview linkPreview;
    public  AdapterRecyclerView(TwitterDataTest allDataActivity, int custom_data_main_layout , List<AllDataModel> allDataArrayList) {
        this.context = allDataActivity;
        this.resource = custom_data_main_layout;
        this.allDataArrayList = allDataArrayList;
    }
    public  AdapterRecyclerView(FacebookDataActivity facebookDataActivity, int custom_data_main_layout , List<AllDataModel> allDataArrayList) {

        this.context = facebookDataActivity;
        this.resource = custom_data_main_layout;
        this.allDataArrayList = allDataArrayList;
    }
    public  AdapterRecyclerView(YoutubeDataActivity youtubeDataActivity, int custom_data_main_layout , List<AllDataModel> allDataArrayList) {
        this.context = youtubeDataActivity;
        this.resource = custom_data_main_layout;
        this.allDataArrayList = allDataArrayList;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(resource, parent, false);
        linkPreview =   itemView.findViewById(R.id.link_preview);
        return new MyViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(@NonNull final MyViewHolder myViewHolder, int position) {

        final AllDataModel allDataModel = allDataArrayList.get(position);
        //get values from dataModel
        final String username  = allDataModel.getUsername();
        myViewHolder.UserName.setText(allDataModel.getUsername());

        myViewHolder.PostTime.setText(allDataModel.getPost_creation_time());
        String post_time = allDataModel.getPost_creation_time();
        String post_text = allDataModel.getPost_text();
        String status_type = allDataModel.getStatus_type();
        final String link_Title = allDataModel.getLink_title();
        if(status_type != null) {
            Log.e("#444", status_type);
        }

// setting source images
        final String source = allDataModel.getSource();
        String profileimageURL = allDataModel.getProfile_image_url();
        String PostImageURL = allDataModel.getPost_image_url();
        String postThuumbnailImageURL = allDataModel.getPost_video_thumbnail();
        final String videoId = allDataModel.getVideo_id();
        final String VideoUrl = allDataModel.getPost_video();
        final String link_url = allDataModel.getLink_url();
        if(profileimageURL != null){
            Picasso.with(getContext()).load(profileimageURL).into(myViewHolder.profileCircularImage);

        }

        if(post_text != null){
            myViewHolder.PostText.setVisibility(View.VISIBLE);
            myViewHolder.PostText.setText(allDataModel.getPost_text());
        }
        if(PostImageURL !=  null){
            myViewHolder.mediaFrameLayout.setVisibility(View.VISIBLE);
            myViewHolder.postMediaImage.setVisibility(View.VISIBLE);
            Picasso.with(getContext()).load(PostImageURL).into( myViewHolder.postMediaImage);
        }
        if(postThuumbnailImageURL != null) {
            myViewHolder.mediaFrameLayout.setVisibility(View.VISIBLE);
            myViewHolder.postVideoThumbnailImage.setVisibility(View.VISIBLE);
            Picasso.with(getContext()).load(PostImageURL).into( myViewHolder.postMediaImage);
            Picasso.with(getContext()).load(postThuumbnailImageURL).into( myViewHolder.postVideoThumbnailImage);
            myViewHolder.play_button_image.setVisibility(View.VISIBLE);
            if(videoId != null) {
                myViewHolder.mediaFrameLayout.setVisibility(View.VISIBLE);
                myViewHolder.play_button_image.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        myViewHolder.postMediaImage.setVisibility(View.GONE);
                        myViewHolder.play_button_image.setVisibility(View.GONE);
                        myViewHolder.postVideoThumbnailImage.setVisibility(View.GONE);

                        Intent youtubePlayerIntent = new Intent((Activity)context, YoutubePlayerActivity.class);
                        youtubePlayerIntent.putExtra("video_id", videoId);
                        context.startActivity(youtubePlayerIntent);

                    }
                }
                );

            }

            if (VideoUrl != null) {
                myViewHolder. play_button_image.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        myViewHolder.postVideoThumbnailImage.setVisibility(View.GONE);
                        myViewHolder.play_button_image.setVisibility(View.GONE);
                        myViewHolder.postVideoView.setVisibility(View.VISIBLE);
                        try {
                            MediaController mediaController = new MediaController(getContext());
                            mediaController.setAnchorView( myViewHolder.postVideoView);
                            Uri video = Uri.parse(VideoUrl);
                            myViewHolder.postVideoView.setMediaController(mediaController);
                            myViewHolder.postVideoView.setVideoURI(video);
                            myViewHolder.postVideoView.requestFocus();
                            myViewHolder.postVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                                public void onPrepared(MediaPlayer mp) {
                                    myViewHolder.postVideoView.start();
                                }
                            });
                        } catch (Exception e) {
                            Log.e("Video Play Error :" , e.toString());
                        }
                    }
                });

            }
            if(status_type != null){
                if(status_type.equals("album") || status_type.equals("share") && source.equals("facebook")){
                    Log.e("STA2",status_type);
                    myViewHolder.play_button_image.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            myViewHolder. play_button_image.setVisibility(View.GONE);
                            myViewHolder.postVideoThumbnailImage.setVisibility(View.GONE);
                            Intent webViewIntent = new Intent(context, WebViewActivity.class);
                            webViewIntent.putExtra("link_url", link_url);
                            context.startActivity(webViewIntent);
                        }
                    });
                }

            }

        }

        if(status_type != null){
            if(status_type.equals("share") && source.equals("twitter") && link_Title!=null ){
                myViewHolder.linkCardView.setVisibility(View.VISIBLE);
                myViewHolder.linkPreview.setData(link_Title);
                myViewHolder.linkPreview.setListener((Preview.PreviewListener) this);
                myViewHolder.linkPreview.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent webViewIntent = new Intent(context, WebViewActivity.class);
                        webViewIntent.putExtra("link_url", link_Title);
                        context.startActivity(webViewIntent);
                    }
                });

            }

        }

        myViewHolder.shareutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final Dialog dialog = new Dialog(context);
                dialog.setContentView(R.layout.share_dialogue);
                dialog.show();
                Button fbShareBtn = (Button)dialog.findViewById(R.id.share_facebook_button);
                Button twitterShareBtn = (Button)dialog.findViewById(R.id.share_twitter_button);
                Button cancel = (Button)dialog.findViewById(R.id.cancel_share);
                final String link_url = allDataModel.getLink_url();
                fbShareBtn.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent facebookIntent = new Intent(context, FacebookLoginActivity.class);
                        facebookIntent.putExtra("link_url", link_url);
                        facebookIntent.putExtra("source", source);
                        context.startActivity(facebookIntent);
                    }
                });
                twitterShareBtn.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent twitterLoginIntent = new Intent(context, MainActivity.class);
                        twitterLoginIntent.putExtra("link_url", link_url);
                        context.startActivity(twitterLoginIntent);
                    }
                });

                cancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                    }
                });
            }
        });
        myViewHolder.postComment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                myViewHolder.commentET.setVisibility(View.VISIBLE);
            }
        });

        myViewHolder.postLike.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                myViewHolder.postLiked.setVisibility(View.VISIBLE);
                myViewHolder.postLike.setVisibility(View.GONE);

            }
        });
        myViewHolder.postLiked.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                myViewHolder. postLike.setVisibility(View.VISIBLE);
                myViewHolder.postLiked.setVisibility(View.GONE);
            }
        });
    }

    @Override
    public int getItemCount() {
        return  allDataArrayList.size();

    }

@Override
public void onDataReady(Preview preview) {
    linkPreview .setMessage(preview.getLink());
}

}

code for main activity  -
public class TwitterDataTest extends AppCompatActivity {
    RecyclerView recyclerView;
    AdapterRecyclerView adapterRecyclerView;
    public List<AllDataModel> allDataArrayList;
    ProgressDialog pd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_twitter_test);
        allDataArrayList = new ArrayList<>();
        recyclerView = findViewById(R.id.twitter_recycler_view);
        recyclerView.setHasFixedSize(true);
        pd = new ProgressDialog(this);
        pd.setTitle("Loading......");
        pd.show();
        if(isOnline()){
            Api apiService =
                    ApiClient.getClient().create(Api.class);
            Call<ResponseBody> call = apiService.getTwitterData();
            call.enqueue(new Callback<ResponseBody>() {
                @Override
                public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                    if(response.isSuccessful()){
                        try {
                            assert response.body() != null;
                            String s = response.body().string();
                            LoadIntoListView(s);
                            recyclerView.setAdapter(adapterRecyclerView);
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                    else{
                        Toast.makeText(TwitterDataTest.this, "No response", Toast.LENGTH_SHORT).show();
                    }

                }
                @Override
                public void onFailure(Call<ResponseBody> call, Throwable t) {

                }
            });

        }
        else{
            Toast.makeText(TwitterDataTest.this, "Please check your internet connection", Toast.LENGTH_LONG).show();
        }
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        adapterRecyclerView = new AdapterRecyclerView(TwitterDataTest.this, R.layout.custom_data_main_layout, allDataArrayList);
         adapterRecyclerView.notifyDataSetChanged();
        recyclerView.setAdapter(adapterRecyclerView);

    }

    public void LoadIntoListView(String s) {
        pd.dismiss();

        try {
            JSONArray jsonArray1 = new JSONArray(s);
            int ja1length = jsonArray1.length();

            for (int i = 0; i < ja1length; i++) {
                String source = "twitter";
                String videoThumbnailImageUrl = null;
                String TweetVideoUrl = null;
                String TweetImageUrl = null;
                String expanded_url = null;
                String url = null;
                String link_url = null;

                JSONObject jsonObject1 = jsonArray1.getJSONObject(i);
                //    String TweetTime = jsonObject1.getString("created_at");
                String TweetText = jsonObject1.getString("full_text");
                String id = jsonObject1.getString("id");
                link_url = "https://twitter.com/AmritDki/status/" + id;

                String createdTime = jsonObject1.getString("created_at");
                final String TWITTER = "EEE MMM dd HH:mm:ss ZZZZZ yyyy";
                SimpleDateFormat sf = new SimpleDateFormat(TWITTER);

                sf.setLenient(true);
                String TwitterCreationDateIST = String.valueOf(sf.parse(createdTime));

                SimpleDateFormat formatter;
                formatter = new SimpleDateFormat("dd-M-yyyy hh:mm:ss a");
                String dateIST_customFormat = formatter.format(sf.parse(createdTime));

                if (TweetText.contains("http") == true) {
                    int index = TweetText.indexOf("https");
                    TweetText = TweetText.substring(0, index );
                }
                // user json object
                JSONObject userJO = jsonObject1.getJSONObject("user");
                String UserName = userJO.getString("name");
                String ScreenName = userJO.getString("screen_name");
                String ProfileImageUrl = userJO.getString("profile_image_url_https");

                // getting entities object
                if (jsonObject1.has("extended_entities")) {

                    JSONObject ExtendedEntitiesJO = jsonObject1.getJSONObject("extended_entities");
                    ///////
                    JSONArray MediaJA = ExtendedEntitiesJO.getJSONArray("media");
                    for (int j = 0; j < MediaJA.length(); j++) {
                        JSONObject insideMediaJO = MediaJA.getJSONObject(j);

                        if (insideMediaJO.has("video_info")) {
                            videoThumbnailImageUrl = insideMediaJO.getString("media_url_https");
                            JSONObject VideoInfoJO = insideMediaJO.getJSONObject("video_info");
                            JSONArray variantsArray = VideoInfoJO.getJSONArray("variants");
                            JSONObject videoUrlJO = variantsArray.getJSONObject(0);
                            TweetVideoUrl = videoUrlJO.getString("url");
                            //allDataArrayList.add(new TwitterDataModel(ProfileImageUrl, UserName,TweetVideoUrl, TweetImageUrl, TweetText));
                            allDataArrayList.add(new AllDataModel(source, UserName, ProfileImageUrl,
                                    TweetText, TweetImageUrl, videoThumbnailImageUrl, TweetVideoUrl, dateIST_customFormat, null,link_url,null, null));
                        } else {
                            TweetImageUrl = insideMediaJO.getString("media_url_https");
                            allDataArrayList.add(new AllDataModel(source, UserName, ProfileImageUrl,
                                    TweetText, TweetImageUrl, videoThumbnailImageUrl, TweetVideoUrl, dateIST_customFormat, null,link_url,null, null));
                        }

                    }
                }

                else{

                    JSONObject entitiesJO = jsonObject1.getJSONObject("entities");
                    if(entitiesJO.has("urls")){
                        JSONArray urlsArray = entitiesJO.getJSONArray("urls");
                        if(urlsArray.length() > 0){
                            JSONObject insideUrlsJO = urlsArray.getJSONObject(0);
                            if(insideUrlsJO.has("expanded_url")){
                                expanded_url = insideUrlsJO.getString("expanded_url");
                                allDataArrayList.add(new AllDataModel(source, UserName, ProfileImageUrl,
                                        TweetText, TweetImageUrl, videoThumbnailImageUrl, TweetVideoUrl, dateIST_customFormat,
                                        null,link_url, "share",expanded_url));
                            }

                        }else{
                            allDataArrayList.add(new AllDataModel(source, UserName, ProfileImageUrl,
                                    TweetText, TweetImageUrl, videoThumbnailImageUrl, TweetVideoUrl, dateIST_customFormat,
                                    null,link_url, null,null
                            ));

                        }

                    }
                }
                Log.e("#**", String.valueOf(allDataArrayList.size()));
               // adapterRecyclerView = new AdapterRecyclerView(TwitterDataTest.this, R.layout.custom_data_main_layout, allDataArrayList);
              //  adapterRecyclerView.notifyDataSetChanged();
                //recyclerView.setAdapter(adapterRecyclerView);
            }

        } catch (JSONException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            Log.e("parsingError", String.valueOf(e));
        }

    }

A: I got the solution of my problem after investing 3-4 hours. I was using the getContext() instead of context (Comes through the constructor)in inflating the layout.Small stupid mistake.


text: Q: What are the conditions on a distance function on a manifold, that there exists a Riemannian metric which gives the same distance Looking at the qeustion(Existence of a Riemannian metric inducing a given distance.), it answered that not all distance functions will have a corresponding Riemannian metric. My question is then, what are the conditions for some metric function to have a corresponding metric? An example in the linked question's answer is using a consequence of Gauss's lemma, but this does not seem to be sufficient in and of itself.


text:
Q: Вычленение кусков текста в текстовом файле [Java] У меня есть SVG файл из которого необходимо вычленить элементарные составляющие такие как:
<rect x="0" y="0" width="400" height="400" fill="none" stroke="black" stroke-width="5px" stroke-opacity="0.5"/>

и записать их как объекты. Как можно автоматизировать этот процесс быстро и просто?
Имеется в виду как вычленить сам элемент, что я привел в примере, из документа. И как его вычленить если он разнесен на несколько строк.
Например, здесь мой код не считывает элемент path:
<g>
            <polygon class="st53" points="351.7,230 378,171.9 323,157 316.3,220.4           "/>
            <path class="st1" d="M353.6,166.6c1.2,0.6,2.6,1.2,4.3,1.9c2.3,0.8,5.1,1.6,7.9,2c2.8,0.4,5.8,0.5,8.5,0.3l-1.2-9.5
                c-2.1,0.3-4.5,0.7-6.9,0.9c-2.4,0.2-4.8,0.2-7,0.2c-1.8-0.1-3.4-0.3-4.7-0.4c0.4-0.4,0.8-0.8,1.1-1.2c1.8-1.8,9.6-11.7,11.2-14
                l-6.3-3.9c-0.7,1.3-7,10.4-7.7,11.9c0.2-2.6-1.2-14.5-1.4-17l-7.3,0.9c0.5,3.1,2.9,15.8,3.6,18.7c0.2,0.8,0.3,1.8,0.6,2.8
                c-1.1-0.5-2.5-1.1-4-1.9c-1.9-1-4-2.3-5.9-3.7c-2-1.4-3.9-2.9-5.5-4.3l-5.8,7.6c2.2,1.6,4.8,3,7.4,4.1c2.7,1.1,5.4,1.8,7.8,2.3
                c1.7,0.3,3.3,0.5,4.6,0.6l-7,25.8l-19.7-5.4l-0.8,7.1l18.6,5.1l-7.3,27l6.8,1.8l7.3-27l18.6,5.1l2.9-6.5l-19.7-5.4L353.6,166.6z"
                />
        </g>
сам код:
    try{
        s = new String(Files.readAllBytes(Paths.get("C:\\Users\\Timur\\Desktop\\SVG\\this_boy_loves_Christmas-4784.svg")));
        //s = s.replace("\n", "").replace("\r", "");
    }catch(IOException e){
    }

    path_pattern = "<path.*/>";
    pattern = Pattern.compile(path_pattern);
    matcher = pattern.matcher(s);
    if (matcher.find()){
        out.println(matcher.group());
    }else{
        out.println("failure");
    }

A: Вобщем я использовал регулярные выражения(regex), за что спасибо пользователю SeniorPomidor
Для многострочных совпадений использовал патерн:
"<path[^/]*/>"


text:
Q: how to split data into minimum groups I wonder if where is an algorithm that can split some data into min groups.
It should looks like,
Precondition: The sum of some number of the data <= m, where m is a explicit number,
expect: Those data split into groups of min count.
Is there an algorithm or good idea?
Thanks.
Here is an example.
List<Integer> rawList = Arrays.asList(1, 1, 1, 2, 10, 5, 8, 3);

You can split them into 8 groups and each group contains 1 number,
which is not what I wanted.
Integer maxSum = 12; //Assume that one group can holds max sum of 12.

I need minimum groups, so the answer looks like
List<Integer> group1 = Arrays.asList(10, 2);
List<Integer> group2 = Arrays.asList(8, 3, 1);
List<Integer> group3 = Arrays.asList(5, 1, 1);

The example above only spent 3 groups to split the raw data.
Those 3 groups will be one answer.(There are others way to use min groups.)
It seems like similar to bin-packaging problem which @Dillon Davis mentioned. Only this one is easier, I think.
Ps. The answer requires minimum groups, time and space complexity is not the major problem.

A: It seems that your problem has strong resemblances to the bin-packing problem. The objective is to pack elements of various sizes into as few bins as possible, each with some fixed capacity. The general approach is to use a greedy algorithm to repeatedly try to pack either the largest element into the first bin it will fit into (first-fit), or to try to fit the largest element into the bin with the least space remaining possible (best-fit). Neither of these guarantee an optimal solution, but usually yield near-optimal results, which may be sufficient.