DEV Community

Calin Baenen
Calin Baenen

Posted on

Why is VSCode trying to run Java when I want to look at the source code of a `.class` file?

I want to look at some code in a .class file in VSCode (which usually works when I do ctrl+lclick on the class I want to view), but instead it brings up the terminal/console as if it's trying to execute the code for no reason.
It randomly does this, so some times it will show a class I want to see, but other times it won't show any thing, and try and run it (sometimes this bug(?) happens on the same class that it let me view earlier (I even tested with classes from java.lang, and only classes from java.lang)).

Any reason(s) why this may happen?

Thanks!
Cheers!

Top comments (7)

Collapse
 
alainvanhout profile image
Alain Van Hout

No idea about your actual question, but I would suggest that you at least have a look at IDEs like IntelliJ (the community edition is free) or Eclipse if you want to do serious Java development.

Collapse
 
calinzbaenen profile image
Calin Baenen

Are you implying not using an IDE, e.g. (like) Eclipse, means that you can't do "serious" Java development?

Collapse
 
alainvanhout profile image
Alain Van Hout

Without an IDE you can of course do a serious exploration of the details of the language. But that's quite different from using Java in a professional setting, which is what my prior use of 'serious' referred to.

It's comparable to using Git (or another modern version control system): you can do coding without it, but you can't do professional software development without it.

Thread Thread
 
calinzbaenen profile image
Calin Baenen

So is VSCode, in that sense, not a "serious" IDE?

Thread Thread
 
thefern profile image
Fernando B 🚀

Give intellij a try, in opens class files with no issues. A class file is bytecode, and needs to be disassembled before you can see it, intellij does this on the fly. Vscode is obviously having issues with it. I agree intellij is built solely for Java projects so it is considered a bit more professional. Though using the tool best for the job is entirely up to you. I personally wouldn't use vscode for Java.

Thread Thread
 
calinzbaenen profile image
Calin Baenen

What is VSCode good for then, because now it just seems like shit, with how useless it is to me.

Thread Thread
 
thefern profile image
Fernando B 🚀

I wouldn't say is useless, I use it a lot for web dev, and python. It has tons of extensions and it's great, but for Java it just can't compete with Intellij. Intellj is built specifically for Java, all the way from how you setup projects, setup libraries, even using other jvm languages like kotlin, groovy, etc. Intellj has the whole ecosystem ready for you, built long before vscode was here. It also has great documentation specifically for Java.