When I run a main class in IDEA, it puts the module and its dependencies on a module path. Is it possible to change it to a classpath?
How to run Java 9 application with classpath rather than module path in IDEA?
5.8k Views Asked by ZhekaKozlov At
2
There are 2 best solutions below
0
Marcus
On
To answer the question, the heuristic IDEA uses to run an application with a module path is currently slightly off (IDEA 2018.01). It apparently takes more into consideration than it should.
See IDEA-187390 and IDEA-193714 for details.
So if your current project does not have a module-info file and you still end up with a module path the current case that I know is that you are running the main class from a dependency. Just build a small wrapper inside your project and run the main class from there, that brings you back to the classpath.
Related Questions in JAVA
- I need the BIRT.war that is compatible with Java 17 and Tomcat 10
- Creating global Class holder
- No method found for class java.lang.String in Kafka
- Issue edit a jtable with a pictures
- getting error when trying to launch kotlin jar file that use supabase "java.lang.NoClassDefFoundError"
- Does the && (logical AND) operator have a higher precedence than || (logical OR) operator in Java?
- Mixed color rendering in a JTable
- HTTPS configuration in Spring Boot, server returning timeout
- How to use Layout to create textfields which dont increase in size?
- Function for making the code wait in javafx
- How to create beans of the same class for multiple template parameters in Spring
- How could you print a specific String from an array with the values of an array from a double array on the same line, using iteration to print all?
- org.telegram.telegrambots.meta.exceptions.TelegramApiException: Bot token and username can't be empty
- Accessing Secret Variables in Classic Pipelines through Java app in Azure DevOps
- Postgres && statement Error in Mybatis Mapper?
Related Questions in INTELLIJ-IDEA
- Gradle 8.7 cannot find installed JDK 22 in IntelliJ
- LiveTemplate for TODO shortcut seems not working
- Jetbrains Intellij Works but Fleet does not : "is not recognized as an internal or external command, operable program or batch file."
- Why is there no help text when i write "." in IntelliJ?
- How to enable Kotlin REPL autocomplete
- Selenium error: SessionNotCreatedException | Java, Firefox, everything is updated and should be compatible
- Ubuntu-22.04 File watcher failed repeatedly and has been disabled (External file changes sync might be slow)
- IntelliJ Typescript NoSuchElementException
- I am trying to use h2 in-memory db from my spring boot application, my spring boot version is 3.1.10, but its not connecting to h2 properly
- Is there a new way to undo and redo in the new version of intelliJ
- How to debug a Kotlin/Native application in IntelliJ?
- Why rebuild module does not recompile dependency module, but build module does in IntelliJ Idea?
- Intelij ultimate and spring boot giving me errors
- Minecraft Mod not adding content
- In IntelliJ IDEA Community Edition, can you generate a dependency tree for Maven projects?
Related Questions in JAVA-9
- Thymeleaf: Error resolving template - Tests fail when using Java 9 modules
- Unable to fine related module of `javax.ws.rs.core.MediaType` class
- Java 9 Modules & IntelliJ: how to configure multiple modules
- Error message mentions Java 9 even though I am using Java 11
- Are there any solutions available that would eliminate the need to add `jvm` options when using Java 9 modules?
- Mockito cannot mock this class - Caused by: NoClassDefFoundError: sun/misc/ObjectInputFilter$FilterInfo
- Java9 'asIterator' equivalent implementation in Java8
- Is android system support multi-release jar?
- Vaadin 14, production build and java version 9 not working
- Java module system: how to avoid leaking all packages of transitive modules
- Cannot access 'java.lang.Object' error with new Android Studio Electric Eel
- Distinguish empty Stream, Stream of empty Optionals only, Stream with at least one non-empty Optional
- How to configure java 9 module with many shared java 8 dependencies?
- Issue with Stream processing when migrating from Java 8 to 9
- Modularity for spring boot multi module
Related Questions in JAVA-PLATFORM-MODULE-SYSTEM
- How to solve InaccessibleObjectException ("Unable to make {member} accessible: module {A} does not 'opens {package}' to {B}") on Java 9?
- Why does compilation of public APIs leaking internal types not fail?
- Where should I put unit tests when migrating a Java 8 project to Jigsaw
- How can I handle split packages in automatic modules?
- IntelliJ doesn't Understand java libraries on Java9-ea
- Jigsaw test dependencies in classpath: why is the superclass in another JAR not accessible?
- How is Java 8 modules different from OSGi?
- Where to place module-info.java using Java 9?
- How to express dependency in maven on java ee features for transition to Java 9?
- Is it possible to mix --class-path and --module-path in javac (JDK 9)?
- How many unnamed modules are created in Java 9?
- Mockito in maven using JPMS cannot access a member of class with modifiers "private"
- Spring NoSuchBeanDefinitionException when switching to JPMS (Java Platform Module System)
- Create a personalised JRE with Java 15 on Windows for Linux and Mac
- org.json cannot be resolved to a module?
Related Questions in MODULE-PATH
- fatal error compiling invalid flag --module-path
- Is it possible to mix --class-path and --module-path in javac (JDK 9)?
- Module path problem when looking for a remote EJB in JNDI
- Modulepath and Classpath can't be found in Java Build Path Libraries
- How can I force Gradle to use --module-path instead of -cp?
- Automatically determine what to place on Classpath and Modulepath?
- Removing Class Path and Module Path from an Eclipse Project
- Not able to compile and run a classpath Java Application
- What is the value of adding non-modular jars to the -classpath and modular jars to the --module-path when compiling a module?
- In python, Is it possible to get the path of the invoked from the invoked file?
- Which system modules are on the module path by default?
- In Eclipse, what is the difference between modulepath and classpath?
- Java 9 automatic modules not found
- Inspect --module-path value at runtime
- Loading classes and resources post Java 9
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
If you don't define a module-info, IDEA would set the application and your dependencies on the classpath. Since you have a module-info it's an explicit module so it has to be on the module path. Normally you would handle your dependecies now as automatic-modules.
Howsoever, your dependencies at least have a good reason to be on the classpath. We discussed that here Why Java 9 does not simply turn all JARs on the class path into automatic modules?
For example, mymodule depends on an automatic-module which however needs a jar that can't become an automatic-module yet. On commandline it would like this:
java -cp legacy.jar -p "mymodule.jar;automodule.jar;" -m mymodule/com.example.mymodule.Application
IMO intellij doesn't currently support that. As a workaround to run the entire application on the classpath at least, you could rename the model-info for disabling/not to be a jigsaw-module for a moment.