I want to set up Kafka source code with IntelliJ IDEA and I am able to successfully build the project but the Run configurations are incorrect.
I have loaded and successfully build the Gradle project in IDEA. I looked around and found a blog post that configures this but some of the run configurations he stated are just not possible. For eg, there is no class kafka.Kafka and the -cp flag is not core_main as stated in the module.
My setup is as following:
How do I setup the run configurations so that I can execute and debug Kafka's source code?
The kafka.Kafka is here. It is a scala class.
Install Scala plugin. Press double shift shortcut and go to Kafka.scala file. Click on the green triangle next to the main method. This will create a run configuration. You can then edit it to add any custom stuff.
Related
I have a large mostly-Java multi-project Gradle build that I have opened in IntelliJ IDEA. This was imported correctly (as far as I can tell). One of the projects inside this is an old-school Java Swing GUI application.
When I attempt to run its main class from within IntelliJ using the "Run Main.main()" context menu, IntelliJ launches a Gradle task ":folder:project:Main.main()", which fails because of course there is no task in this project's build.gradle called "Main.main()".
The exact error looks like:
Execution failed for task ':folder:project:Main.main()'.
> A problem occurred starting process 'command 'C:/path/to/ojdk8/bin/java.exe''
What exactly am I expected to put into my build.gradle to get this to work?
As a secondary question, is it possible to make such a task agnostic over the actual main()-method containing class? This project contains several such classes that expose different functionality.
For context, I am a long-time Eclipse user evaluating IntelliJ for my organization. This is on IntelliJ IDEA 2022.1, Gradle 5.6.4, OpenJDK 1.8.0_275
I feel like I am missing something completely obvious, but I could not find the answer with any web searching or reading the IntelliJ documentation.
My mental model of what was happening was wrong. No specific Gradle tasks are required.
It turns out the root cause was Windows. When re-running the task with --stacktrace option I was able to see the actual error, which turned out to be:
CreateProcess error=206: The filename or extension is too long
Googling with this info I found this previous Stackoverflow question. Its answered got me onto the "Shorten command line" flag in the Run/Debug configuration. Setting this to "JAR manifest" solved the problem.
Not an expert but Gradle is what the (Spring Boot) project is using. I have a #Component which runs setting up dummy data, but I only want it to run locally. So now I have put an #Profile("local123") over it too and this turns the component off. Great.
Next I wanted to put in Eclipse's Run Configurations... > JVM Arguments the -Dspring.profiles.active=local123 so that the component is turned on but only when I'm running my build locally. No joy. I have seen some posts that say you need to add this or similar to build.gradle
bootRun {
systemProperties System.properties
}
but anywhere I try to add it in the file, it causes my build to crash.
Where am I going wrong? and/or
Where do I get documentation on the structure of build.gradle to work out where this should go!
I used the Maven archetype maven-archetype-quickstart at the command-line to generate a new project. I imported that project into IntelliJ 2017.1.
How do I run the app?
How to debug the app?
The green triangle button to run the app is disabled.
I opened the panel listing Maven lifecycle and plugins. But I do not see any action for running the app.
When running the application itself, within IntelliJ, you will have to open the App.java-file in order to run it. From there, right-click and select Run within the static main()-method. In the same context-menu, you also have to option to select Debug.
Running the application from Maven is however not possible based on the archtype. Maven may rather help you package the entire thing. However, executing the jar-file post-build is quite simple - as explained in the documentation found here:
https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App
I am executing a code that does some database operations.
It performs well when I execute it using the Run command in Eclipse.
But when I execute it in debug mode, I get the source not found
The JAR file mysql-connector-java-5.1.39-bin.jar has no source attachment
You're trying to step into code provided by mysql-connector-java, and you haven't linked in an source code for Eclipse to actually step-in-to.
The easiest thing to do would be to step over that line (since you probably don't care about it) rather than trying to debug the connector code. You may also want to tweak your debugger settings to prevent exceptions from pausing your execution.
As #nitind points out you can also filter types, packages, and patterns so the debugger avoids stepping through them.
If that doesn't work or you do need to step into the connector code you'll need to download a source jar (from Maven) and attach it in your project's build configuration.
Debugging in eclipse program works with the class actually loaded.
The problem you posted looks like the class you are using was not found in the project, but is present without debug info in a distribution jar.
This can be solved most likely by altering the build path of the project to stop using this jar and have the JVM using the project.
or you can try mvn clean eclipse:eclipse
This is happening because the debugger is running into some class file...
To view this, either download the source code and attach it or install some class decompiler plugin (I am using JAD Eclipse Plugin). The first solution is better.
I have an existing Java project set up in Intellij 12 and am attempting to add some Groovy classes to it. I've started with attempting to add a simple Spock class for testing purposes, but when I right-click on the class it does not give me an option to run it.
I've taken a look at my Intellij configuration and it pulls in groovy correctly. Further, I can write a Groovy script that uses a Groovy class and that runs without problems so it appears that Groovy is wired in. Is there something else I need to configure to specifically run Spock tests?
Easiest way to get spock and all dependencies is add library from maven.
Then, you should place your test in a folder, marked as test folder, if you want to allow batch processing of them.
If you place your script in folder, not marked as test, or source folder, you will be unable to run it.
If you can't see run button, it looks like Idea cannot recognise file as runnable, it isn't under source/test root, or it's extension is invalid.
You can add Spock plugin by:
Downloading the jar
In IDEA File->Settings->Plugins->Install from disk. Choose the jar.
I was having the same issue and ended up here. I found that I had forgotten to extend spock.lang.Specification. As soon as I did, the Run option showed up.
Just posting in case it helps any other Spock novices like myself.