java编译不了代码,有没有办法在不编译的情况下运行短代的Java代码?

Is there a way to run or simulate running Java statements (kind of like IDLE - the Python GUI) without compiling and running the executable? I want to quickly test statements to see if they work. Thanks.

解决方案

Yep, you can use Eclipse, create a single project, and create a Scrapbook Page in that project.

a0yrF.jpg

Scrapbook pages get their classpath

from the containing project's build

path. If in a scrapbook page you want

to reference a Java element that is

not on the build path of the

containing Java project, you need to

add to the Java project's build path.

Scrapbook pages also allow you to

specify import statements. You do this

by selecting Set Imports from the

context menu of a scrapbook page or

Set Import Declarations for Running

Code from the toolbar. You need to set

import statements for references to

Java declarations in your projects.

This is a common oversight. If the

type or package you are attempting to

import is not listed in the Add

dialog, it means you need to add it to

the build path of the project

containing the scrapbook page. If you

are referencing an element that has

multiple declarations, you will need

to add an import statement to uniquely

identify the element.

Edit: Got another solution too: http://ideone.com. It's an online IDE and debugging tool. You can see an example here: http://ideone.com/98sA8, but it looks like you have to set up a bit more than on a scrapbook page.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值