How to run Java scratch file in IntelliJ IDEA

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 03:27:12

问题


I just start using IntelliJ-14 and I want to know about a scratch file. If I create a java scratch can I compile this as a normal Java class. What I Have Already Tried Create a Java class in a scratch file but unable to find any way to compile this. What I am looking for rather than creating a new Java file in an existing project for running some test code I just want to use scratch file and write some test class with the main method and after complete running close the scratch file. Is that possible?


回答1:


Executability for Java scratch files was added in IntelliJ 15, so you must upgrade for that feature.

You have several option how to run/debug the scratch file:

  • Click the icon next to the main method/class
  • Hit Control+Shift+R (Control+Shift+F10 on Linux/Windows) somewhere within the scratch file
  • Right click inside the method/class and select appropriate run/debug option



来源:https://stackoverflow.com/questions/33562958/how-to-run-java-scratch-file-in-intellij-idea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!