Spring boot 2 Address already in use - java

I have a spring boot application which is a cron job that runs daily.
I recently migrated my spring boot application to 2.1.6 from 1.5.10 and Java from 8 to 11.
When deployed in the server this app is throwing an Exception:
java.net.BindException: Address already in use
It was working fine on the lower version.
I made sure there is no other services running on the port 8590.
Below is my gradle file:
plugins {
id 'org.springframework.boot' version '2.1.6.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
apply plugin: 'jdepend'
sourceCompatibility = 1.11
bootJar {
baseName = 'alerts-service'
}
checkstyle {
ignoreFailures = true
toolVersion = '8.2'
configDir = file("$rootProject.projectDir/etc/checkstyle")
System.setProperty('checkstyle.cache.file', String.format('%s/%s', buildDir, 'checkstyle.cachefile'))
}
repositories {
maven {
url "http://repo/repository/cmp-maven-releases"
}
maven {
url "http://repo/repository/cmp-maven-snapshots"
}
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-jdbc') {
exclude group: 'org.apache.tomcat', module: 'tomcat-jdbc'
}
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-mail')
compile("org.apache.axis:axis:1.4")
compile('org.apache.commons:commons-lang3:3.5')
compile('org.apache.httpcomponents:httpclient:4.3.4')
compile('org.apache.pdfbox:pdfbox:2.0.1')
compile("com.itextpdf:itextpdf:5.1.3")
compile("com.itextpdf:itext-xtra:5.1.3")
compile("com.itextpdf.tool:xmlworker:1.1.1")
compile("net.sf.ehcache:ehcache:2.10.3")
compile("commons-discovery:commons-discovery:0.5")
compile("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.8.4")
compile('ch.qos.logback:logback-core:1.1.8')
compile('ch.qos.logback:logback-classic:1.1.8')
compile("wsdl4j:wsdl4j:1.6.2")
compile("javax.jms:jms:1.1")
compile("com.ibm:mq-mqjms:7.0.1")
compile('org.springframework:spring-jms:4.3.3.RELEASE')
runtime("com.ibm:mq-commonservices:7.0.1")
runtime("com.ibm:mq-headers:7.0.1")
runtime("com.ibm:mq:7.0.1")
runtime("com.ibm:mq-jmqi:7.0.1")
runtime("com.ibm:mq-pcf:7.0.1")
runtime("net.sf.jt400:jt400-full:5.4")
runtime("com.ibm:mq-mqcontext:7.0.1")
runtime("com.ibm:mq-dhbcore:7.0.1")
runtime("javax.transaction:jta:1.1")
runtime('com.microsoft:sqljdbc4:4.0')
testRuntime('com.h2database:h2')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile group: 'junit', name: 'junit', version: '4.4'
}
I have the port specified in my application.properties
server.port=8590
I tried with the below property as well that did not work
management.server.port=8590
management.endpoints.web.exposure.include=*
management.endpoint.shutdown.enabled=true
endpoints.shutdown.enabled=true
Any hints would be greatly appreciated.
EDIT :
I tried killing the PID of this service and triggered startup script. I did work and for the next execution it thrown the same error again.
Looks like somehow shutdown has to happen after each execution.
srartup.sh
nohup /opt/jdk-11.0.2/bin/java -Xmx768m -Xms256m -Dlogging.config=/opt/runnables/alerts-service/logback.xml -jar /opt/runnables/alerts-service/alerts-service.jar --spring.profiles.active=qa &> logs/console.log&

Check which process is using the port,
In windows
netstat -ano | find "8080"
In linux
netstat -nap | grep 8080
If someone else is using that port, you have to use another port or kill that other process and let the port free.

Finally I found the solution. By adding the application context closing tag has worked for me in main class.
SpringApplication.run(AlertsApplication.class, args).close();

Related

Build Gradle Failed

I'm following Google Drive API instruction to upload file to google drive with java, when i try to "gradle run" in cmd, it announces that "BUILD FAILED" with "Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'"
I'm using java jre 1.8 and gradle 5.4.1 on Eclipse
Here is my build.gradle
apply plugin: 'java'
apply plugin: 'application'
mainClassName = 'DriveQuickstart'
sourceCompatibility = 11
targetCompatibility = 11
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
implementation 'com.google.api-client:google-api-client:1.33.0'
implementation 'com.google.oauth-client:google-oauth-client-jetty:1.32.1'
implementation 'com.google.apis:google-api-services-drive:v3-rev20211107-1.32.1'
}
i change
sourceCompatibility = 11
targetCompatibility = 11
to
sourceCompatibility = 1.8
targetCompatibility = 1.8
and it worked, so it depends on your jdk version

Alpine Docker Image to run JLink executable

My current Docker image is approximately 200MB. My goal is to reduce that as much as possible, so I thought the alpine image would be a great way to achieve that. However, I keep encountering roadblocks.
It's a multi-module libGDX project that uses Java 14 and its preview features, along with JLink (from JPackage) to produce a custom (lightweight) JRE.
I only care to deploy the server module, which depends on the common module (which the client module also uses).
I'll be providing all the necessary files below, but in case I'm missing something, here is a link to the repo: https://github.com/payne911/marvelous-bob/tree/dev
Current problem
I either get:
when executing ./server: file not found for an executable file which I know exists and is executable where I'm trying to run it in the Docker Image
when executing apk add --no-cache someLibrary: a segfault: core dumped when trying to download libraries in my ENTRYPOINT which I thought were required to execute that file (libstdc++ and libc6-compat)
Goal
Reusable lightweight Docker Image which contains everything to run libGDX executables generated by JLink.
Current files which are in a working state and I'm trying to refactor
Dockerfile
FROM openjdk:14-jdk-alpine
COPY server/build/libs/server-all.jar /app.jar
COPY utils/deploys/bootstrap.sh /bootstrap.sh
RUN chmod +x /bootstrap.sh
EXPOSE 80
ENTRYPOINT ["./bootstrap.sh"]
bootstrap.sh
#!/usr/bin/env sh
echo "========== LAUNCHING SERVER APP ========="
apk add --no-cache libstdc++
java --enable-preview -jar /app.jar
build.gradle files
root
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
}
}
// to force download of sources and JavaDoc
plugins {
id 'java'
id 'idea'
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
allprojects {
version = '1.0'
ext {
appName = "marvelous-bob"
gdxVersion = '1.9.10'
roboVMVersion = '2.3.7'
box2DLightsVersion = '1.5'
ashleyVersion = '1.7.0'
aiVersion = '1.8.2'
slf4j = '1.7.26'
logback = '1.2.3'
lombok = '1.18.12'
kryonet = '2.22.6'
reflectionsVersion = '0.9.12'
pieMenuVersion = '4.2.0'
shapeDrawer = '2.3.0'
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
maven { url 'https://jitpack.io' }
}
}
project(":desktop") {
apply plugin: "java-library"
dependencies {
api project(":client")
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
}
}
project(":client") {
apply plugin: "java-library"
dependencies {
api project(":common")
api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
api "space.earlygrey:shapedrawer:$shapeDrawer"
api "com.github.payne911:PieMenu:$pieMenuVersion"
}
}
project(":server") {
apply plugin: "java-library"
dependencies {
api project(":common")
api "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
}
}
project(":common") {
apply plugin: "java-library"
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
api "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
api "com.badlogicgames.gdx:gdx-ai:$aiVersion"
// todo: do we need both logging libraries? p.s. kryonet uses Minlog
api "org.slf4j:slf4j-api:$slf4j"
api "ch.qos.logback:logback-classic:$logback"
api "com.github.crykn:kryonet:$kryonet"
api "org.reflections:reflections:$reflectionsVersion"
}
}
common
plugins {
id 'java'
id 'io.freefair.lombok' version '5.1.0'
}
sourceCompatibility = 14
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
tasks.withType(JavaCompile) {
options.compilerArgs += "--enable-preview"
}
tasks.withType(Test) {
jvmArgs += "--enable-preview"
}
tasks.withType(JavaExec) {
jvmArgs += '--enable-preview'
}
sourceSets.main.java.srcDirs = [ "src/" ]
jar {
from('src') {
include '**/*.properties'
}
}
server
plugins {
id 'java'
id 'io.freefair.lombok' version '5.1.0'
id 'com.github.johnrengelman.shadow' version '5.2.0'
}
sourceCompatibility = 14
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
tasks.withType(JavaCompile) {
options.compilerArgs += "--enable-preview"
}
tasks.withType(Test) {
jvmArgs += "--enable-preview"
}
tasks.withType(JavaExec) {
jvmArgs += '--enable-preview'
}
sourceSets.main.java.srcDirs = [ "src/" ]
jar {
project.version="" // to remove version number from the built jar's name
manifest {
attributes 'Main-Class': 'com.marvelousbob.server.BobServerLauncher'
}
}
GitHub Actions yml file
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Setup with Java 14
id: java-setup
uses: actions/setup-java#v1
with:
java-version: 14
- name: Allow GitHub Actions to run Gradlew
run: chmod u+x gradlew
- name: Run Gradle build
id: gradle-build
uses: eskatos/gradle-command-action#v1
with:
arguments: shadowJar
# more stuff ...
What I've tried
So many things, for days! Here was the state of my last attempt.
Dockerfile
FROM alpine:3.7
COPY server/build/jpackage/server /server
FROM openjdk:14-jdk-alpine
COPY server/build/libs/server-all.jar /app.jar
COPY utils/deploys/bootstrap.sh /bootstrap.sh
RUN chmod +x /bootstrap.sh
EXPOSE 80
ENTRYPOINT ["./bootstrap.sh"]
bootstrap.sh
#!/bin/sh
echo "========== LAUNCHING SERVER APP ========="
cd /server/bin
chmod +x server
./server
build.gradle
root
Same as other one.
common
Same as other one.
server
plugins {
id 'java'
id 'io.freefair.lombok' version '5.1.0'
id 'org.beryx.runtime' version '1.8.4'
}
sourceCompatibility = 14
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
tasks.withType(JavaCompile) {
options.compilerArgs += "--enable-preview"
}
tasks.withType(Test) {
jvmArgs += "--enable-preview"
}
tasks.withType(JavaExec) {
jvmArgs += '--enable-preview'
}
sourceSets.main.java.srcDirs = [ "src/" ]
mainClassName = "com.marvelousbob.server.BobServerLauncher"
task dist(type: Jar) {
project.version="1" // adjust the CI/CD if you change this
manifest {
attributes 'Main-Class': project.mainClassName
}
from {
configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
destinationDirectory = file("$buildDir/lib")
}
jpackageImage.dependsOn dist
dist.dependsOn classes
// JLink configuration to minimize size of generated jar
runtime {
options = ['--strip-debug',
'--compress', '2',
'--no-header-files',
'--no-man-pages',
'--strip-native-commands',
'--vm', 'server']
modules = ['java.base' ,
'java.desktop',
'jdk.unsupported']
distDir = file(buildDir)
jpackage {
//jpackageHome = '/usr/lib/jvm/open-jdk'
mainJar = dist.archiveFileName.get()
}
}
Github Actions yml file
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Setup with Java 14
id: java-setup
uses: actions/setup-java#v1
with:
java-version: 14
- name: Building with Gradlew
run: |
chmod u+x gradlew
./gradlew server:jpackageImage
# more stuff ...
#deduper seems to have figured it out (see https://chat.stackoverflow.com/rooms/222569/discussion-between-deduper-and-payne), but I didn't have time to go back and make sure his analysis is right.
In theory, it does make a lot of sense, so I'm posting it nonetheless as an answer:
I'm pretty sure the main cause of the errors you describe in your question is because you built the runtime on either Windows 10 or Ubuntu; then tried to deploy and run the runtime on Alpine.
I won't accept my answer because I haven't made a confirmation of this yet, but I'm nonetheless posting it in case others encounter this problem and want a probable clue.

Error:Abnormal build process termination, while compiling kotlin file in IntelIj

Trying to compile kotlin file in Intelij and getting the following error with long trace:
Error:Abnormal build process termination:
/home/stayal0ne/Desktop/kotlin-env/jdk-8u171-linux-arm64-vfp-hflt/jdk1.8.0_171/bin/java -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs=\"\" -Djdt.compiler.useSingleThread=true -Dpreload.project.path=/home/stayal0ne/trash/KotlinTelegramBot -Dpreload.config.path=/home/stayal0ne/.IntelliJIdea2018.1/config/options -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Djava.net.preferIPv4Stack=true -Dio.netty.initialSeedUniquifier=-2445885864882950180 -Dfile.encoding=UTF-8 -Duser.language=en -Duser.country=US -Didea.paths.selector=IntelliJIdea2018.1 -Didea.home.path=/home/stayal0ne/Downloads/idea/idea -Didea.config.path=/home/stayal0ne/.IntelliJIdea2018.1/config -Didea.plugins.path=/home/stayal0ne/.IntelliJIdea2018.1/config/plugins -Djps.log.dir=/home/stayal0ne/.IntelliJIdea2018.1/system/log/build-log -Djps.fallback.jdk.home=/home/stayal0ne/Downloads/idea/idea/jre64 -Djps.fallback.jdk.version=1.8.0_152-release -Dio.netty.noUnsafe=true -Djava.io.tmpdir=/home/stayal0ne/.IntelliJIdea2018.1/system/compile-server/kotlintelegrambot_48229f77/_temp_ -Djps.backward.ref.index.builder=true -Dkotlin.incremental.compilation=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=\"/tmp/kotlin-idea-6368009607740488460-is-running\" -classpath /home/stayal0ne/Downloads/idea/idea/lib/jps-launcher.jar:/home/stayal0ne/Desktop/kotlin-env/jdk-8u171-linux-arm64-vfp-hflt/jdk1.8.0_171/lib/tools.jar:/home/stayal0ne/Downloads/idea/idea/lib/optimizedFileManager.jar org.jetbrains.jps.cmdline.Launcher /home/stayal0ne/Downloads/idea/idea/lib/platform-api.jar:/home/stayal0ne/Downloads/idea/idea/lib/annotations.jar:/home/stayal0ne/Downloads/idea/idea/lib/guava-21.0.jar:/home/stayal0ne/Downloads/idea/idea/lib/commons-logging-1.2.jar:/home/stayal0ne/Downloads/idea/idea/lib/aether-dependency-resolver.jar:/home/stayal0ne/Downloads/idea/idea/lib/idea_rt.jar:/home/stayal0ne/Downloads/idea/idea/lib/nanoxml-2.2.3.jar:/home/stayal0ne/Downloads/idea/idea/lib/snappy-in-java-0.5.1.jar:/home/stayal0ne/Downloads/idea/idea/lib/netty-all-4.1.13.Final.jar:/home/stayal0ne/Downloads/idea/idea/lib/httpclient-4.5.2.jar:/home/stayal0ne/Downloads/idea/idea/lib/jna.jar:/home/stayal0ne/Downloads/idea/idea/lib/log4j.jar:/home/stayal0ne/Downloads/idea/idea/lib/jps-builders.jar:/home/stayal0ne/Downloads/idea/idea/lib/asm-all.jar:/home/stayal0ne/Downloads/idea/idea/lib/jgoodies-forms.jar:/home/stayal0ne/Downloads/idea/idea/lib/aether-1.1.0-all.jar:/home/stayal0ne/Downloads/idea/idea/lib/util.jar:/home/stayal0ne/Downloads/idea/idea/lib/javac2.jar:/home/stayal0ne/Downloads/idea/idea/lib/resources_en.jar:/home/stayal0ne/Downloads/idea/idea/lib/trove4j.jar:/home/stayal0ne/Downloads/idea/idea/lib/jps-model.jar:/home/stayal0ne/Downloads/idea/idea/lib/oro-2.0.8.jar:/home/stayal0ne/Downloads/idea/idea/lib/jps-builders-6.jar:/home/stayal0ne/Downloads/idea/idea/lib/httpcore-4.4.5.jar:/home/stayal0ne/Downloads/idea/idea/lib/jna-platform.jar:/home/stayal0ne/Downloads/idea/idea/lib/protobuf-java-3.0.0.jar:/home/stayal0ne/Downloads/idea/idea/lib/maven-aether-provider-3.3.9-all.jar:/home/stayal0ne/Downloads/idea/idea/lib/lz4-java-1.3.jar:/home/stayal0ne/Downloads/idea/idea/lib/forms_rt.jar:/home/stayal0ne/Downloads/idea/idea/lib/slf4j-api-1.7.10.jar:/home/stayal0ne/Downloads/idea/idea/lib/commons-codec-1.9.jar:/home/stayal0ne/Downloads/idea/idea/lib/jdom.jar::/home/stayal0ne/Downloads/idea/idea/plugins/gradle/lib/gradle-api-4.4.jar:/home/stayal0ne/Downloads/idea/idea/plugins/gradle/lib/gradle-api-impldep-4.4.jar:/home/stayal0ne/Downloads/idea/idea/lib/ant/lib/ant.jar:/home/stayal0ne/Downloads/idea/idea/lib/groovy-all-2.4.12.jar:/home/stayal0ne/Downloads/idea/idea/lib/gson-2.8.2.jar:/home/stayal0ne/Downloads/idea/idea/lib/slf4j-api-1.7.10.jar:/home/stayal0ne/Downloads/idea/idea/lib/slf4j-log4j12-1.7.10.jar:/home/stayal0ne/Downloads/idea/idea/lib/gson-2.8.2.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/jarutils.jar:/home/stayal0ne/Downloads/idea/idea/lib/guava-21.0.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/android-base-common.jar:/home/stayal0ne/Downloads/idea/idea/plugins/gradle/lib/gradle-api-4.4.jar:/home/stayal0ne/Downloads/idea/idea/lib/gson-2.8.2.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/jarutils.jar:/home/stayal0ne/Downloads/idea/idea/lib/guava-21.0.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/android-base-common.jar:/home/stayal0ne/Downloads/idea/idea/plugins/gradle/lib/gradle-api-4.4.jar:/home/stayal0ne/Downloads/idea/idea/plugins/ant/lib/ant-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/uiDesigner/lib/jps/ui-designer-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/IntelliLang/lib/intellilang-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/Groovy/lib/groovy-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/Groovy/lib/groovy-rt-constants.jar:/home/stayal0ne/Downloads/idea/idea/plugins/eclipse/lib/eclipse-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/eclipse/lib/common-eclipse-util.jar:/home/stayal0ne/Downloads/idea/idea/plugins/maven/lib/maven-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/maven/lib/plexus-utils-2.0.6.jar:/home/stayal0ne/Downloads/idea/idea/plugins/osmorc/lib/osmorc-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/osmorc/lib/bndlib-3.3.0.jar:/home/stayal0ne/Downloads/idea/idea/plugins/osmorc/lib/bnd-repository-3.3.0.jar:/home/stayal0ne/Downloads/idea/idea/plugins/osmorc/lib/bnd-resolve-3.3.0.jar:/home/stayal0ne/Downloads/idea/idea/plugins/osmorc/lib/plexus-utils-3.0.10.jar:/home/stayal0ne/Downloads/idea/idea/plugins/osmorc/lib/bundlor-all.jar:/home/stayal0ne/Downloads/idea/idea/plugins/aspectj/lib/aspectj-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/flex/lib/flex-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/flex/lib/flex-shared.jar:/home/stayal0ne/Downloads/idea/idea/plugins/gradle/lib/gradle-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/devkit/lib/devkit-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/JavaEE/lib/javaee-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/JavaEE/lib/jps/jpa-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/webSphereIntegration/lib/jps/webSphere-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/weblogicIntegration/lib/jps/weblogic-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/dmServer/lib/dmServer-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/GwtStudio/lib/gwt-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/GoogleAppEngine/lib/google-app-engine-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/GoogleAppEngine/lib/appEngine-runtime.jar:/home/stayal0ne/Downloads/idea/idea/plugins/Grails/lib/grails-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/Grails/lib/grails-compiler-patch.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/jps/android-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/android-common.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/build-common.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/android-rt.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/sdk-common.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/repository.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/sdklib.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/android-base-common.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/jarutils.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/layoutlib-api.jar:/home/stayal0ne/Downloads/idea/idea/plugins/android/lib/manifest-merger.jar:/home/stayal0ne/.IntelliJIdea2018.1/config/plugins/Kotlin/lib/jps/kotlin-jps-plugin.jar:/home/stayal0ne/.IntelliJIdea2018.1/config/plugins/Kotlin/lib/kotlin-stdlib.jar:/home/stayal0ne/.IntelliJIdea2018.1/config/plugins/Kotlin/lib/kotlin-reflect.jar:/home/stayal0ne/.IntelliJIdea2018.1/config/plugins/Kotlin/lib/kotlin-plugin.jar:/home/stayal0ne/.IntelliJIdea2018.1/config/plugins/Kotlin/lib/android-extensions-ide.jar:/home/stayal0ne/.IntelliJIdea2018.1/config/plugins/Kotlin/lib/android-extensions-compiler.jar:/home/stayal0ne/Downloads/idea/idea/plugins/javaFX/lib/javaFX-jps-plugin.jar:/home/stayal0ne/Downloads/idea/idea/plugins/javaFX/lib/common-javaFX-plugin.jar org.jetbrains.jps.cmdline.BuildMain 127.0.0.1 41993 1e0f5647-4e35-4812-b8b7-bd7025d7eae3 /home/stayal0ne/.IntelliJIdea2018.1/system/compile-server
/home/stayal0ne/Desktop/kotlin-env/jdk-8u171-linux-arm64-vfp-hflt/jdk1.8.0_171/bin/java: 6: /home/stayal0ne/Desktop/kotlin-env/jdk-8u171-linux-arm64-vfp-hflt/jdk1.8.0_171/bin/java: Syntax error: ")" unexpected
Tried to use various jdk versions and all of them show the same error.
Main.kt:
import org.telegram.*
import org.telegram.telegrambots.TelegramBotsApi
import org.telegram.telegrambots.api.objects.Update
import org.telegram.telegrambots.bots.TelegramLongPollingBot
import java.util.*
fun main(args : Array<String>) {
println("Hello, world!")
}
and build.gradle:
buildscript {
ext.kotlin_version = '1.2.41'
repositories {
maven { url "http://repo.maven.apache.org/maven2/" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: "java-library"
apply plugin: "kotlin"
apply plugin: "java"
apply plugin: 'application'
mainClassName = 'main.Main'
repositories {
// mavenCentral()
maven { url "http://jcenter.bintray.com" }
}
dependencies {
implementation 'org.hibernate:hibernate-core:3.6.7.Final'
api 'com.google.guava:guava:23.0'
testImplementation 'junit:junit:4.+'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
dependencies {
compile "org.telegram:telegrambots:3.6"
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
I'm building the project using gradle 4.8 and java version "1.8.0_171".
Any help will be appreciated
/home/stayal0ne/Desktop/kotlin-env/jdk-8u171-linux-arm64-vfp-hflt/jdk1.8.0_171/bin/java
You are using an arm64 JDK, which may not be your current hardware platform. You should reinstall JDK with platform x86_64 or other which fits your hardware.
Also, it seems you are using Linux, then you may use package manager to install the correct version of JDK and JRE automatically, like sudo apt install openjdk-8-jdk. (It doesn't matter to use OracleJDK or OpenJDK)

gradle jetty plugin does not stop when using daemon=true in jettyRun

I'm using the following gradle script for very simple web application:
apply plugin: 'war'
apply plugin: 'jetty'
repositories {
mavenCentral()
}
dependencies {
providedCompile deps['servlet-api']
providedCompile deps['commons-io']
providedCompile deps['gson']
}
jettyRun {
contextPath = "/"
httpPort = 8900
stopPort = 9800
stopKey = "pleaseStop"
daemon = true
}
jettyStop {
stopPort = 9800
stopKey = "pleaseStop"
}
When I run jettyRun the app works but when I run jettyStop it does not stop.
If I change daemon to false jettyStop does stop the embedded Jetty server.
How can I stop the embedded Jetty server when use in daemon mode?

Wait for user input while debugging on IntelliJ IDEA and Gradle

I have the simplest Java application that just works if executed from command line. But if I want to debug it through IntelliJ IDEA 14 Ultimate, the System.in.read() part always returns -1, without ever typing anything into it:
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
System.out.println("This is a test... Hit [enter] to exit.");
int cha = System.in.read();
System.out.println("You hit [enter], exiting...");
}
}
Is this some kind of issue with Windows 8.1 or is it IntelliJ IDEA related?
UPDATE: I have found out the issue presents itself only when starting the application through Gradle (gradlew run), so it's a Gradle issue. This is my build.gradle:
apply plugin: 'java'
apply plugin: 'application'
sourceCompatibility = 1.7
targetCompatibility = 1.7
version = '1.0'
mainClassName = 'net.frakbot.ws.Main'
repositories {
mavenCentral()
}
run {
main = 'net.frakbot.ws.Main'
standardInput = System.in
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}
It is has been a known bug in Intellij Idea: bug description
EDIT: Apparently, as pointed out in the comments, it has been fixed since this answer was given and patched Intellij will be released in Summer 2017.
It's working fine on my windows 7 machine with IntelliJ IDEA 14 community edition.

Categories

Resources