首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在java项目中构建和创建./parking_lot文件

如何在java项目中构建和创建./parking_lot文件
EN

Stack Overflow用户
提问于 2022-05-28 12:22:39
回答 1查看 34关注 0票数 0

请看一下这个git回购:

https://github.com/rohitdang/ParkingLot

在根文件夹中,有一个名为"parking_lot“的名称。要运行这个文件,我所要做的就是输入终端:

代码语言:javascript
复制
./parking_lot <inputFile.path>

我希望创建一个类似的文件来执行maven项目,以便在根文件夹中以类似的方式运行我的项目。我使用的是java-11和IntelliJ的想法。

请帮帮我。谢谢。

EN

回答 1

Stack Overflow用户

发布于 2022-05-28 20:17:33

parking_lot (https://github.com/rohitdang/ParkingLot/blob/master/parking_lot)是以以下内容开头的文件:

代码语言:javascript
复制
#!/bin/sh
MYSELF=`which "$0" 2>/dev/null`
[ $? -gt 0 -a -f "$0" ] && MYSELF="./$0"
java=java
if test -n "$JAVA_HOME"; then
    java="$JAVA_HOME/bin/java"
fi
java_args=-Xmx1g
exec "$java" $java_args -jar $MYSELF "$@"
exit 1 
PK^C^D

这是一个有效的shell脚本,重新启动java -jar本身。这将有效,因为parking_lot也是一个有效的jar文件,如

代码语言:javascript
复制
ravn@freewifi Downloads % jar tvf parking_lot
     0 Wed Oct 18 01:29:26 CEST 2017 META-INF/
   183 Wed Oct 18 01:29:24 CEST 2017 META-INF/MANIFEST.MF
     0 Wed Oct 18 01:29:24 CEST 2017 com/
     0 Wed Oct 18 01:29:24 CEST 2017 com/gojek/
     0 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/
     0 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/
     0 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/Exception/
     0 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/inputargconfigfactory/
     0 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/parkinglotfactory/
   720 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/Exception/InternalServerErrorException.class
   687 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/Exception/NotFoundException.class
  1680 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/inputargconfigfactory/FileParser.class
   988 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/inputargconfigfactory/InputArgumentConfigFactory.class
  1629 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/inputargconfigfactory/InputArgumentParser.class
   921 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/inputargconfigfactory/ParkingLotConfig.class
   809 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/ParkingLot.class
   898 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/parkinglotfactory/Car.class
  1877 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/parkinglotfactory/CreateParkingLot.class
  1942 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/parkinglotfactory/Leave.class
  2303 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/parkinglotfactory/Park.class
  1774 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/parkinglotfactory/ParkingLotConfigFactory.class
  2519 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/parkinglotfactory/RegistrationNumberForCarWithColours.class
  2986 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/parkinglotfactory/SlotNumberForCarWithColours.class
  3043 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/parkinglotfactory/SlotNumberForCarWithRegistrationNumber.class
  1998 Wed Oct 18 01:29:24 CEST 2017 com/gojek/parkinglot/ParkingLot/parkinglotfactory/Status.class
    60 Wed Oct 18 01:29:22 CEST 2017 file_input_invalid.txt
   418 Wed Oct 18 01:29:22 CEST 2017 file_inputs_valid.txt
   397 Wed Oct 18 01:29:22 CEST 2017 file_inputs_without_creating_parking_lot.txt
     0 Wed Oct 18 01:29:26 CEST 2017 META-INF/maven/
     0 Wed Oct 18 01:29:26 CEST 2017 META-INF/maven/com.gojek.parkinglot/
     0 Wed Oct 18 01:29:26 CEST 2017 META-INF/maven/com.gojek.parkinglot/ParkingLot/
  1666 Wed Oct 18 01:24:22 CEST 2017 META-INF/maven/com.gojek.parkinglot/ParkingLot/pom.xml
   124 Wed Oct 18 01:29:24 CEST 2017 META-INF/maven/com.gojek.parkinglot/ParkingLot/pom.properties

(这是可能的,因为jar文件是zip文件,它们是从文件末尾读取的。紧跟在PK之后的exit 1是压缩头的第一位)

我猜想该文件是通过将shell脚本与Maven生成的jar文件连接起来创建的。为此使用cat命令。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72415669

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档