r/learnjava • u/ILLOGICAAAL • 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...
- My code
- Compilation
-> javac com/Orynth/Outer.java
- 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
View all comments
Show parent comment
2
u/ILLOGICAAAL Feb 23 '26
Ya..., as you said you tried it on zsh , but in the zsh, dollar sign '$' has special meaning it treats any word written after $ as variable
Now when you do -> com.example.test$inner
Then it treat inner as something which have value but in java code inner is not a variable. That's why it ignores inner and treat command as normal
-> com.example.test
But in Windows CMD it is giving me different answer and that is the right answer I want .
Thanks man..👍🏻
By the way it is very interesting to know different behaviour of terminal and shell