I have a java project in intelliJ and I've added a few modules, one of which has scala code in it.
I want to tell intelliJ to compile this module with scalac not javac, but I can't figure out where to configure it, and when I try to compile it gives me this error, "Cannot create instance of scalac"
Per https://intellij-support.jetbrains.com/hc/en-us/community/posts/206001829-Project-configuration-explained:
A module that requires compiling with Scalac should have a Scala facet attached.
And further down (what I think you want):
To add Scala support to existing module:
Right-click the module in Project View, choose "Add Framework Support..."
Check "Scala" in technologies list (unavailable if module has Scala facet attached)
Provide a path to Scala installation (if not detected)
Related
I'm trying to create a simple modular programming application.
My project consists of two modules-
com.module.model
com.module.util
when I'm trying to export the module com.module.model in module-info.java.
IntelliJ cannot find the package to import.
(However it should give me the error of module not found)
The same problem stands for 'requires module' too.
I have provided all the modules in the dependencies for com.module.model
Solutions I already tried-
Build the modules separately (before adding the export line) and the whole project (maven clean install) as whole.
Invalidated caches and restarted.
SDK and Language level is set to 11.
You need to create those packages com.module.model and the like within the java folder of your IntelliJ project.
Within IntelliJ, the directory that you've named as com.module.model is the "IntelliJ module" name and has no relation with the "Java module system", in that you would be using the artifact generated out of this project.
To add a screenshot on the similar lines as of the question. It would look like:
I am using gradle to build a java project.
I see that whenever there is a change in one java file entire projects gets rebuilt. Is there a way to compile only affected java files instead of all the files.
Gradle now supports compile avoidance, and has support for incremental compilation since earlier. You do not have to do anything to enjoy these features. Just update Gradle. See https://blog.gradle.org/incremental-compiler-avoidance
Typically when adding a JAR to include with Gradle compilation I do the following:
compile files('lib/sentiment-models.jar')
However, since the JAR I'm trying to include is quite big (200MB) my goal is to instead include it at runtime, similar to how you would add files to the classpath using the java command:
java -cp lib/sentiment-models.jar:. -jar /app/server.jar
So is there a way to use gradle run while including files at runtime, preferably in the build.gradle config file?
Thanks!
Update
I also tried
runtime files('lib/sentiment-models.jar')
but it doesn't seem to work.
I believe that you are using the Java plugin. Please check the documentation, section Dependency management. Try this one:
compileOnly Compile time only dependencies, not used at runtime
This should compile your project and the huge jar should not be included in the distribution. How you will refer it in runtime largely depends on your project type.
Intellij Idea add Scala support to existing Java project.
Just cannot figure it out How to add Scala worksheet to existing Java project?
It would be just nice to have Scala REPL or worksheet.
But after resiarsh and trying I failed to do that.
To add Scala support to existing module:
Right-click the module in Project View, choose “Add Framework Support…”
Check “Scala” in technologies list (unavailable if module has Scala facet attached)
Provide a path to Scala installation (if not detected)
From http://blog.jetbrains.com/scala/2010/09/02/project-configuration-explained/.
I have a project (Java Swing application), in which I want to mix Java and Groovy.
I can compile and run the project without problems inside IntelliJ Idea.
But I can't compile it with Maven:
In src/main/groovy I define a Groovy class GroovyClass.
In src/main/java there is a Java class, which uses GroovyClass.
When compiling the project with Maven, I get the message [ERROR] ...\JavaClass.java:[13,47] error: cannot find symbol.
How can I change the pom.xml file in order to be able to compile and package the application using Maven?
Add the groovy-eclipse compiler maven plugin to your pom.xml
Instructions are on the plugins page at https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-Maven-plugin