java.lang.ClassNotFoundException,命令行制作问题和bash脚本编写

时间:2019-03-01 12:37:28

标签: java bash scripting classnotfoundexception

我是bash脚本的新手,无法找到适合的修补程序,并且可以在Web上理解。这个问题看似经典,但我输了。

我尝试制作自己的命令行,可以直接在Ubuntu的bash终端上使用。我使用备用.bash_profile来确保避免包含默认bash环境设置的.bashsr文件出现问题。我使用source .bash_profile

加载设置

然后我有自己的/ bin_onyr目录,在其中放置.sh脚本,以便创建自己的命令以及具有要使用的别名的脚本,并具有对其他脚本的访问权限。

问题,我明白了:

  

onyr @ kenzae:〜$ source .bash_profile欢迎Onyr。很高兴见到你   再次。 of gameoflife 10 12 15错误:找不到或加载主类   GameOfLife.class造成原因:java.lang.ClassNotFoundException:   GameOfLife.class

我想将Java程序GameOfLife.class转换为可以直接使用的命令行。该程序可以在有或没有传递参数的情况下工作。

onyr@kenzae:~$ cd Documents/computer_sciences/tp_java/10_tp_game_of_life/
onyr@kenzae:~/Documents/computer_sciences/tp_java/10_tp_game_of_life$ java GameOfLife
frameNumber0 
.  .  .  .  .  .  .  .  .  .  .  . 
 .  X  .  .  X  .  X  X  .  X  .  . 
 .  .  .  X  .  .  .  .  .  .  X  . 
 .  X  X  X  .  .  .  .  X  .  .  . 
 .  X  .  .  .  X  X  .  .  .  X  . 
 .  X  X  X  .  .  X  X  .  X  .  . 
 .  .  .  .  .  .  .  .  .  .  .  .

我不知道该怎么办。贝娄是我的剧本。请帮忙:

/ home / onyr中的

.bash_profile

#This is a personal alternative to the original .bashrc environment settings
echo "Welcome Onyr. Pleased to see you again."
export PS1="ʘ "
#get the aliases for personnal commands
chmod +x ./bin_onyr/bash_aliases_onyr.sh #grant run permission
source ./bin_onyr/bash_aliases_onyr.sh
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/$
#test
alias greet3="~/bin_onyr/greetings_codecademy.sh 3"
/ p / home / onyr / bin_onyr中的

bash_aliases_onyr

#!/bin/bash
#grant run permission for shell command line bash files
chmod +x ~/bin_onyr/greetings_codecademy.sh
chmod +x ~/bin_onyr/gameoflife.sh
# This file contains my own command aliases
alias greet3="~/bin_onyr/greetings_codecademy.sh 3" #3 is default value
alias greet="~/bin_onyr/greetings_codecademy.sh" #here there must be an agrument ex: greet 4
alias gameoflife="~/bin_onyr/gameoflife.sh" #the game of life displayed
/ home / onyr / bin_onyr中的

gameoflife.sh

#!/bin/bash
cd /home/onyr/Documents/computer_sciences/tp_java/10_tp_game_of_life/
java GameOfLife.class $@

GameOfLife.class位于不同的目录/ home / onyr / Documents / computer_sciences / tp_java / 10_tp_game_of_life /

0 个答案:

没有答案