Wait for user input while debugging on IntelliJ IDEA and Gradle - java

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.

Related

Command line version of IntelliJ IDEA run configuration

I have a working IntelliJ IDEA run configuration. It uses Spring Boot.
I'd like to execute the same run from the MacOS command line. How can I get IntelliJ IDEA to show the command (or commands) that I need execute the run configuration.
This is the gradle build.gradle file:
plugins {
id 'org.springframework.boot' version '2.6.4'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'org.mountsinai'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = "15"
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
runtimeOnly 'com.microsoft.sqlserver:mssql-jdbc'
implementation group: 'org.springframework', name: 'spring-aspects', version: '5.3.15'
implementation group: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect', version: '3.0.0'
implementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.7.0'
implementation group: 'com.github.pcj', name: 'google-options', version: '1.0.0'
implementation 'com.google.code.gson:gson:2.9.0'
}
tasks.named('test') {
useJUnitPlatform()
minHeapSize = "1024m" // initial heap size
maxHeapSize = "2048m" // maximum heap size
}
targetCompatibility = JavaVersion.VERSION_15
And this is the configuration element in the ./.idea/workspace.xml corresponding to the run I'd like to automate on the command line:
<configuration name="IrwMetadataIntegrationApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<module name="org.mountsinai.IRWMetadataIntegration.main" />
<option name="SPRING_BOOT_MAIN_CLASS" value="org.mountsinai.IRWMetadataIntegration.IrwMetadataIntegrationApplication" />
<option name="PROGRAM_PARAMETERS" value="--algorithm=batch --numOfStudiesToRetrieve=600" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="15" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
My original question can now be asked more concretely How can one convert an IDEA configuration and workspace.xml file into a command (or script) that can be executed outside IntelliJ IDEA?
Using
IntelliJ IDEA 2021.3.2 (Ultimate Edition) Build #IU-213.6777.52, built on January 27, 2022
Thanks, Arthur
At the top of your console
Notice there's a command something something... java, normally it collapses into such short form, but if you click on that:
Notice it will expand and show you the full command:
In this case, for example, ultimately, the command is something like this:
/Users/hoaphan/.sdkman/candidates/java/17.0.4-amzn/bin/java -XX:TieredStopAtLevel=1
-Dspring.output.ansi.enabled=always
-Dcom.sun.management.jmxremote
-Dspring.jmx.enabled=true
-Dspring.liveBeansView.mbeanDomain
-Dspring.application.admin.enabled=true
...blahblahblahblahblah...
com.example.bootgradlej17.Bootgradlej17Application
So you can mimic intelliJ by running such long command.
But I would suggest if this is springboot, and build by gradle, what you actually want to do is at project root, in the dir where your build.gradle is do:
./gradlew bootRun
Now if you want to mimic the JVM option IntelliJ did, you can just capture such info from an IntelliJ run using tool like VisualVM:
Then you can configure your bootRun to start with such config for JVM like:
bootRun {
jvmArgs = "-Dspring.application.admin.enabled=true", "-Dnannana=nenenene" (etc)....
}
Execute your program through the run configuration and check the first line of the output. It should contain the call that is executed by the IDE, often something like java -jar ….
e.g. when running a Scratch file, I get the following in the output window as first line:
/usr/lib/jvm/java-1.11.0-openjdk-amd64/bin/java -javaagent:/home/user/bin/idea-IU-222.3345.47/lib/idea_rt.jar=37117:/home/user/bin/idea-IU-222.3345.47/bin -Dfile.encoding=UTF-8 -classpath /home/user/.cache/JetBrains/IntelliJIdea2022.3/compile-server/backend_dd2372d5/scratches/out:... Scratch
Continuing my comment above ...
On my computer (running macOS Big Sur 11.6) VisualVM cannot find the JVM arguments:
Instead, they can be found in the java command that you explain how to reveal. E.g., mine are:
-Dspring.output.ansi.enabled=always
-Dcom.sun.management.jmxremote
-Dspring.jmx.enabled=true
-Dspring.liveBeansView.mbeanDomain
-Dspring.application.admin.enabled=true
...
Please explain your
bootRun {
jvmArgs = "-Dspring.application.admin.enabled=true", "-Dnannana=nenenene" (etc)....
}
example. Where and how should this text be used?
One also needs to provide any command-line arguments that are in the IDEA configuration. These can be passed via the gradlew --args option, like this:
--args='--algorithm=batch --numOfStudiesToRetrieve=600'
Overall, however, this approach is more ad hoc than I'd like. It requires that one hack a) IDEA's java command to obtain the JVM arguments, b) the command-line arguments in via gradlew's --args. But I assume that the silence of IntelliJ IDEA's developers indicates that they do not support this important functionality.
Another comment in an answer because the formatting limitations of comments are so limiting:
Thanks, #HoaPhan. However, when I insert a bootRun section like this in build.gradle,
bootRun {
jvmArgs = "-Dspring.output.ansi.enabled=always"
}
IntelliJ IDEA raises
Could not compile build file '<path>/build.gradle'.
> startup failed:
build file '<path>/build.gradle': 1: Unexpected input: '{' # line 1, column 9.
bootRun {
^
This appears to occur wherever the section is placed in the file.
However, this does work:
bootRun {
jvmArgs = [ "-Dspring.output.ansi.enabled=always",
"-Dcom.sun.management.jmxremote",
"-Dspring.jmx.enabled=true",
"-Dspring.liveBeansView.mbeanDomain",
"-Dspring.application.admin.enabled=true",
"-Dfile.encoding=UTF-8"
]
}
It's unclear why the first bootRun { appears to generate a syntax error and this does not.

Switch from Java 8 to Java 11 in my IntelliJ gradle project, a issue comes at runtime

I was using Java 8 for my gradle project, now I installed Java 11 & try to switch to using Java 11.
My Java 11 version details:
My gradle project has following configuration in build.gradle file:
plugins {
id 'org.springframework.boot' version '2.5.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.my.webapp.xi'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
...
...
As you can see above I have sourceCompatibility = '11' now, it used to be sourceCompatibility = '8'.
In my IntelliJ Project strucutre settings, I have chosen Java 11 instead of 8 as well:
There is no issue building the project. But when I run my java gradle project my Intellij gives me this error:
If above screenshot error is not enough, here is the complete error message from Intellij:
> Process 'command '/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
When I was using Java 8 (in both build.gradle & the settings of Intellij) it was fine without any issue but when I switch to Java 11 this issue comes,
I also tried switching to Java 16, I get the same issue.
What am I missing? What could be the reason? Where should I check?
After I restarted my IntelliJ, the error disappeared.
#akortex, I would like to take a screenshot to convince you that line of error is the only message on console. But I can't reproduce it anymore. If I misunderstand you, it would be nice if you could tell more about "full error", do you mean some other places to check the error or use some command with verbose flag?

IntelliJ + Gradle + JavaFX building, but not running

I'm trying to run Gradle project with JavaFX in IntelliJ IDEA Ultimate on Windows. JavaFX was added in our latest Git push, before it was working.
I can build project without problems. I'm getting an errror while running main:
I have:
JDK 11.0.5 (the one from Oracle site, not openJDK), I'm using Java 11, all configured in IntelliJ
JDK installation directory (specifically /bin directory in it) added to my PATH
JAVA_HOME environment variable added with JDK installation directory
Project structure:
build.gradle (it was not built by me, I don't understand exactly what is written there and why):
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.8'
}
group 'transportCompany'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile 'org.mongodb:mongodb-driver-sync:3.11.2'
compile group: 'org.openjfx', name: 'javafx', version: '11.0.2', ext: 'pom'
}
javafx {
version = "11.0.2"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
Main.java:
public class TransportCompanyApp extends Application {
private Stage primaryStage;
private MainAppPresenter presenter;
#Override
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("My first JavaFX app");
presenter = new MainAppPresenter(primaryStage);
this.presenter.initRootLayout();
//this.primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
If I understand correctly, IntelliJ sees all files, there are no unresolved references in code, all imports work.
JavaFX jars are downloaded by Gradle:
They are configured as "Libraries", not "Global libraries", since they shouldn't be, with Gradle it should just be built, download everything and run, if I understand correctly.
I've tried creating new project with Git Checkout, it didn't work. Curiously though it worked for my colleagues (they have the same setup: JDK 11, Java 11, Windows; some even don't have JAVA_HOME at all and it works for them).
What I've tried:
JavaFX getting started
Error: JavaFX runtime components are missing, and are required to run this application with JDK 11
Error: JavaFX runtime components are missing - JavaFX 11 and OpenJDK 11 and Eclipse IDE
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000909940-Openjfx-11
https://openjfx-dev.openjdk.java.narkive.com/aFiw9uqi/error-javafx-runtime-components-are-missing-and-are-required-to-run-this-application
using JDK 13 and Java 13
changing project to modular
using JavaFX as Global Library and importing it to modules
What else can I do? I just want Gradle to download whatever I need and run this project. We've done that at university with JavaFX introduction with similar project and it did work on my current configuration (the only difference was that that one was with Maven).
EDIT
After running gradlew --info run I got:
> Task :run FAILED
Task ':run' is not up-to-date because:
Task has not declared any outputs despite executing actions.
Starting process 'command 'C:\Program Files\Java\jdk-11.0.5\bin\java.exe''. Working directory:
C:\Users\Lenovo\Desktop\TO Command: C:\Program Files\Java\jdk-11.0.5\bin\java.exe --add-modules
javafx.controls,javafx.fxml --module-path C:\Users\Lenovo\.gradle\caches\modules-2\files-2.1\o
rg.openjfx\javafx-fxml\11.0.2\b3242e4c031558574de2a1da685bb5fcdbb8a530\javafx-fxml-11.0.2-win.j
ar;C:\Users\Lenovo\.gradle\caches\modules-2\files-2.1\org.openjfx\javafx-controls\11.0.2\6c7637
07769c18adce406904c771c2ad1fcc370b\javafx-controls-11.0.2-win.jar;C:\Users\Lenovo\.gradle\cache
s\modules-2\files-2.1\org.openjfx\javafx-graphics\11.0.2\20459ea2cf714942bcbeb78a7f70ba3531dc1a
44\javafx-graphics-11.0.2-win.jar;C:\Users\Lenovo\.gradle\caches\modules-2\files-2.1\org.openjf
x\javafx-base\11.0.2\1852e57b8cf9a9b6488c33605bccd5d06ff210e1\javafx-base-11.0.2-win.jar -Dfile
.encoding=windows-1250 -Duser.country=PL -Duser.language=pl -Duser.variant -cp C:\Users\Lenovo\
Desktop\TO\build\classes\java\main;C:\Users\Lenovo\Desktop\TO\build\resources\main;C:\Users\Len
ovo\.gradle\caches\modules-2\files-2.1\org.mongodb\mongodb-driver-sync\3.11.2\a011ecee75c110e95
d33ece066f4bee149d5487a\mongodb-driver-sync-3.11.2.jar;C:\Users\Lenovo\.gradle\caches\modules-2
\files-2.1\org.openjfx\javafx\11.0.2\6e90384c9fb4ec7ed8186c0e916c419c87a24cbf\javafx-11.0.2.pom
;C:\Users\Lenovo\.gradle\caches\modules-2\files-2.1\org.openjfx\javafx-fxml\11.0.2\b3242e4c0315
58574de2a1da685bb5fcdbb8a530\javafx-fxml-11.0.2-win.jar;C:\Users\Lenovo\.gradle\caches\modules-
2\files-2.1\org.openjfx\javafx-controls\11.0.2\6c763707769c18adce406904c771c2ad1fcc370b\javafx-
controls-11.0.2-win.jar;C:\Users\Lenovo\.gradle\caches\modules-2\files-2.1\org.openjfx\javafx-c
ontrols\11.0.2\4ab633cf1eea60f76e2ae9905aedac862da88b08\javafx-controls-11.0.2.jar;C:\Users\Len
ovo\.gradle\caches\modules-2\files-2.1\org.openjfx\javafx-graphics\11.0.2\20459ea2cf714942bcbeb
78a7f70ba3531dc1a44\javafx-graphics-11.0.2-win.jar;C:\Users\Lenovo\.gradle\caches\modules-2\fil
es-2.1\org.openjfx\javafx-graphics\11.0.2\e522eb4ea422eceeee207b1c266ba3db19b2343a\javafx-graph
ics-11.0.2.jar;C:\Users\Lenovo\.gradle\caches\modules-2\files-2.1\org.openjfx\javafx-base\11.0.
2\1852e57b8cf9a9b6488c33605bccd5d06ff210e1\javafx-base-11.0.2-win.jar;C:\Users\Lenovo\.gradle\c
aches\modules-2\files-2.1\org.openjfx\javafx-base\11.0.2\7fb2e4a8528ec9e434a9ac9ee98b39af79e6dc
b8\javafx-base-11.0.2.jar;C:\Users\Lenovo\.gradle\caches\modules-2\files-2.1\org.mongodb\mongod
b-driver-core\3.11.2\798e2d948326c5bfd9924e524bab22ee39c8f4f\mongodb-driver-core-3.11.2.jar;C:\
Users\Lenovo\.gradle\caches\modules-2\files-2.1\org.mongodb\bson\3.11.2\96b17202f1250736ba83021
ff56550e83e8fd8c5\bson-3.11.2.jar TransportCompanyApp
Successfully started process 'command 'C:\Program Files\Java\jdk-11.0.5\bin\java.exe''
Error: Could not find or load main class TransportCompanyApp
Caused by: java.lang.ClassNotFoundException: TransportCompanyApp
:run (Thread[Daemon worker,5,main]) completed. Took 0.367 secs.
FAILURE: Build failed with an exception.
The problem was solved. What I did:
Removed compile group: 'org.openjfx', name: 'javafx', version: '11.0.2', ext: 'pom' as dependency from gradle.build.
Changed mainClassName in gradle.build to mainClassName = "app.TransportCompanyApp".
Changed Run option in IntelliJ to use gradle run.

Spring boot 2 Address already in use

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();

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)

Categories

Resources