在java中写脚本文件_如何在Windows中使用shell脚本调用在Eclipse IDE中编写的java程序而不知道classpath?...

我需要这个概念的帮助 . 我搜索了这个论坛中的几个主题,但没有一个符合我的问题

我使用Eclipse IDE编写了一个Java类,并将.sh文件保存在同一个文件夹中 . 我使用Git Bash运行shell脚本,因为我没有任何其他Linux终端 .

这个脚本文件也应该在另一台机器上运行这个java程序 . (我必须将这些java文件和shell脚本发送给一个评估器,这样当他在他的机器上运行shell脚本时它就会运行)所以我不知道java和classpath设置将如何在另一台机器上 .

当我调用时,我得到如下错误

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

/**

* This class creates two instances of same class

* and performs message transmission.

*

*/

public class App {

final static String initTurn = "initiator";

final static String receiverTurn = "receiver";

public static void main(String[] args) {

App app = new App();

InputStreamReader r = new InputStreamReader(System.in); // Input reader for messages

InputStreamReader totalMessages = new InputStreamReader(System.in); // Input reader to get total number of messages

BufferedReader br = null;

Player initiator = new Player(); /* Instance for Player who initiates the message */

Player receiver = new Player(); /* Instance for player who receives and re-sends the message. */

/ ** some implementations */

}

}

public class Player {

String message;

public String getMessage() {

return message;

}

public void setMessage(String message) {

this.message = message;

}

}

我的shell脚本代码

#!/bin/sh

javac Player.java

javac App.java

java App

当我从Git Bash运行shell脚本时,我收到如下错误 . 所有Java类和脚本文件都在同一个文件夹中 .

App.java:21: error: cannot find symbol

Player initiator = new Player(); /* Instance for Player who initiates the message */

^

symbol: class Player

location: class App

App.java:21: error: cannot find symbol

Player initiator = new Player(); /* Instance for Player who initiates the message */

^

symbol: class Player

location: class App

App.java:22: error: cannot find symbol

Player receiver = new Player(); /* Instance for player who receives and re-sends the message. */

^

symbol: class Player

location: class App

App.java:22: error: cannot find symbol

Player receiver = new Player(); /* Instance for player who receives and re-sends the message. */

^

symbol: class Player

location: class App

4 errors

Error: Could not find or load main class App

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值