创建一个批处理文件,对于简单的javac和java命令执行 [英] Creating a batch file, for simple javac and java command execution

查看:198
本文介绍了创建一个批处理文件,对于简单的javac和java命令执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个非常简单的事情,但我不能让我的头周围。我看过很多的StackOverflow职位和以及在互联网上。

我的目标是创建一个.BAT将打开cmd并执行我的Main.java到命令提示符。容易是吧,但我有困惑,怎么样?

下面我写这我的批处理文件应执行步骤


  1. 开启CMD

  2. 的javac Main.java

  3. Java的主要

所以我假设我不需要给予明确的路径我的文件将驻留旁边,我所有的.java

我的理解迄今为止的研究:


  1. 开启文本编辑器

  2. 写一个code打开CMD(这我不知道如何)

  3. 回声的javac Main.java(仍是模糊的概念对我来说)

  4. 回声的Java主

另存为:name.bat

任何帮助将AP preciated。谢谢你。


解决方案

  1. 打开记事本


  2.  关闭@echojavac的Main.javaJava的主要


3.saveAs blahblah.bat

确保Main.java居住与您的批处理文件和java路径ENV中设定。变量

4。在批处理文件双击,无需打开CMD明确TT将打开本身的.bat执行

It is a really simple thing but I cannot get my head around it. I have looked at plenty of StackOverFlow post and as well as on internet.

My goal is to create a .bat which will open cmd and execute my Main.java into command prompt. Easy isn't it, but I have got confused about how?

Below I am writing steps which my batch file should perform

  1. open cmd
  2. javac Main.java
  3. java Main

My file will reside next to all my .java so I am assuming I don't need to give explicit path.

My understanding so far by research:

  1. open text editor
  2. write a code to open cmd(Which I am not sure how)
  3. echo javac Main.java (Which is still fuzzy concept for me)
  4. echo java Main

Save as: name.bat

Any help will be appreciated. Thank you.

解决方案

  1. open notepad

  2. write

    @echo off
    
    javac Main.java
    
    java Main
    

3.saveAs blahblah.bat

make sure that Main.java resides with your batch file and java path is set in env. variable

4 . double click on batch file, no need to open cmd explicitly tt will open itself on .bat execution

这篇关于创建一个批处理文件,对于简单的javac和java命令执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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