是否可以在使用Java 9的Eclipse IDE中使用没有class和main方法的sysout? [英] Is it possible to use sysout without class and main method in Eclipse IDE using Java 9?

查看:291
本文介绍了是否可以在使用Java 9的Eclipse IDE中使用没有class和main方法的sysout?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于Java 9引入了JShell的概念,它使我们能够在不创建类和方法的情况下编写代码,是否可以在eclipse中使用Java 9的这个特性?

解决方案

您可以使用



或者,您可以使用


As Java 9 introduced the concept of JShell which enables us to write code without creating a class and a method, is it possible to use this feature of Java 9 in eclipse ?

解决方案

You can use the TM Terminal to run JShell in Eclipse:

  • If necessary, install TM Terminal (contained only in some Eclipse packages)
  • Open a 'Terminal' view in Eclipse: Window > Show View > Other...: Terminal > Terminal
  • Launch a new Local Terminal
  • Run JShell, e. g. on Windows type "C:\Program Files\Java\jdk-9\bin\jshell" -v followed by Enter

Alternatively, you can use a Scrapbook Page, a built-in feature of the Eclipse Java IDE and which also works with older Java versions. You will have code completion and you can use Java classes of your project:

这篇关于是否可以在使用Java 9的Eclipse IDE中使用没有class和main方法的sysout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆