r/learnjava • • Feb 23 '26

Behavioral difference between Intellije terminal and Command prompt.

I was testing a java code on Topic- Inner classes and i found something...

  1. My code
package com.Orynth;

class Outer {

    class Inner {
    }

    public static void main(String[] args) {
        System.out.println("outer main method");
    }
}
  1. Compilation

-> javac com/Orynth/Outer.java

  1. Running

-> java com.Orynth.Outer

When running this in Intellije terminal and in Command prompt both give same output.

But, when running Inner.class

-> java com.Orynth.Outer$Inner

It is giving diffrent ans

Intellije terminal giving same output statement which is in outer class But,

Command prompt giving me - Error: main not found in Inner class

The thing is that CMD giving right answer, then why intellije terminal giving diffrent.

2 Upvotes

6 comments sorted by

View all comments

Show parent comment

1

u/Spirited-Fox-135 Feb 24 '26

ya i mean i didn't knew this behav of zsh yet thanks for calling that out