Cannot run class file from command line

Answered

Hello:

I'm a new IntelliJ user coming over from Eclipse.  I have a project which compiles successfully in the IDE but since I'm new to IntelliJ, I wanted to check it out on the command line as well.  Before posting, I looked at this:  https://intellij-support.jetbrains.com/hc/en-us/community/posts/206991865-How-can-I-see-compilation-classpath-ie-the-command-line-

My code is in a package com.dogzilla in the /src directory

The class with the main method is in Runner.java

The project path is C:/Users/dogzilla/IdeaProjects/HelloWorld

After compiling, I see my class files in C:\Users\dogzilla\IdeaProjects\HelloWorld\out\production\HelloWorld\com\dogzilla

When I run from the terminal, java com.dogzilla.Runner I get:  

Error: Could not find or load main class com.dogzilla.Runner

Okay... I get it... it wants the classpath.  So I run this from the terminal:  

java -cp C:\Users\dogzilla\IdeaProjects\HelloWorld\out\production\HelloWorld\com\dogzilla Runner

... which still throws: Error: Could not find or load main class Runner

I don't get it.  Everything in the vendor doc either says to run java -cp or run java package1.packageN.ClassName and neither works.  

Any assistance you could provide is greatly appreciated.

Thanks!

 

 

0
3 comments

While in  C:\Users\dogzilla\IdeaProjects\HelloWorld\out\production\HelloWorld directory run java com.dogzilla.Runner.

2
Avatar
Permanently deleted user

Got it.  Thanks!

0
Avatar
Permanently deleted user

Lifesaver xD

0

Please sign in to leave a comment.