nppexec java,Java使用notepad ++和nppexec进行编译和运行

Please keep in mind that compiling in the windows shell works, so there is little (if not zero) possibility of this issue being a PATH issue.

I have spent a lot of time research how to do this, and all the results I found online say that you can do:

NPP_SAVE

javac $(FILE_NAME)

java $(NAME_PART)

but that does not work for me. In the NPP_EXEC console, I can type java, and I get the normal results as I would from cmd, but any time I type javac, I get the dreaded error code 2 error:

================ READY ================

javac

javac

CreateProcess() failed with error code 2:

The system cannot find the file specified.

================ READY ================

Edit

I must clarify some confusion:

This solution should run in a single script. The goal is to be able to change code, press a hotkey combination (think F5 in Visual Studio) and it builds/compiles and runs.

The actually issue, iirc, was that notepad++ is not recognizing javac for some reason..

Sorry for the confusion...

解决方案

I finally, after 5+ hours of googling and trial and error, have a working NPP Exec script that will compile and run a java program without leaving notepad++.

NPP_SAVE

cmd /K (javac "$(FULL_CURRENT_PATH)" && exit) || exit

cmd /K (cd /D "$(CURRENT_DIRECTORY)" && java $(NAME_PART) && exit) || exit

The only thing left would be finding a way to do the above, without having to call and send parameters to cmd, all in notepad++ and nppexec.

As noted in the comment below, if you're using a package, you will need to edit the second line accordingly. If your package name is the same as your file name, the below should work:

cmd /K (cd /D "$(CURRENT_DIRECTORY)" && java -cp .. $(NAME_PART).$(NAME_PART) && exit) || exit

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值