简体   繁体   中英

Debug compiled Java .class files in VS Code

I'm taking a CS Data Structures course, and I want to try and work with VS Code instead of the current editor that I'm using (BlueJ). However, my work is evaluated based on whether it can satisfy a certain set of tests presented by a compiled tester file (a .class file that I can use to run/check my work), something that VS Code doesn't seem to particularly like.

This tester is what contains the program's main() method, so I either need to use BlueJ (which already supports running compiled classes) or run the file from the command line (something that I know how to do, but have found somewhat tedious) in order to run the method. Is there a way that I could configure a VS Code Java debugger to execute the main() method located within my compiled tester file?

A note: These tester files do not come with editable .java counterparts; if we were able to see what the tester checks for, that would ruin the point of the tester!

Not exactly what you want, But:
For tedious commands, you could set up an alias in your $HOME/.bash_aliases file.
Bash Aliases .

ie one i aliased earlier :

alias ds="java -cp $HOME/javaWorkScripts/jspDatabaseApp/bin/ FormatTabContents $HOME/VSCODE\\ Research/SURFACE-TIDE-JSP-DATABASE-APP-22-DEC-2018.txt "

From now on, you could just type ds in terminal to run the command.

You can decompile and debug the class in IntelliJ easily. Then set break points on main method and check it. You can decompile the class in VS code easily but I doubt you will be able to debug the .class file in VS Code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM