创建jar文件的困难 [英] Difficulties creating a jar file

查看:129
本文介绍了创建jar文件的困难的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Java编辑器编写了一个代码,现在我正在尝试从中创建一个jar文件。从我的早期代码(只是Hello World和东西)中创建一个代码运行良好。但是使用这段代码似乎没有用。 Java编辑器说它压缩到48%然后停止。打开罐子不起作用。我在创建一个jar文件时查了很多教程,但是所有这些都只显示了如何按下顶部的按钮,我做了。我也试过Jarfix(没用)。这里有人可以帮助我吗?

I wrote a code using Java Editor and now I am trying to create a jar File from it. Creating one from my early codes (just Hello World and stuff) worked well. But with this code it seems not to work. Java Editor says that it compressed until 48% and then it stops. Opening the jar does not work. I looked up a lot of "tutorials" on creating a jar file but all of them just showed how to press the button on the top, which I did. I also tried Jarfix (didn't work). Can anyone here help me?

推荐答案


  • 步骤1:创建一个名为 proj (或任何其他名称)到
    将您的工作与现有文件隔离。

  • 步骤2:在步骤1的该目录中,创建另一个目录
    名为 com ,并在 com 中创建另一个名为的目录任务

    • Step 1: Create a directory named proj (or any other name) to isolate your work from existing files.
    • Step 2: Within that directory of step 1, create another directory named com and within com create one more directory named quest.

      步骤3:现在将以下Hello.java放在名为
      quest的目录中。

      Step 3: Now put the following Hello.java in the directory named quest.

      package com.quest;
      public class Hello{
      
      public static void main(String[] args){
          if(args.length==0){
              System.out.println("Hello World");
          }else{
              System.out.println("Hello "+args[0]);
      
          }
       }
      }
      


    • 步骤4:在 proj 目录中创建一个名为 MANIFEST.MF 的文本文件,其中包含以下内容。
      请记住在输入文件的最后一行(此处只有一行)后按Enter键。

    • Step 4: Create a text file named MANIFEST.MF in proj directory with following content. Please remember to press enter after typing the last line (here only one line) of the file.

      Main-Class:com .quest.Hello

      步骤6:使用以下命令创建可执行的hello.jar文件:

      Step 6: Create executable hello.jar file with following command:

      C:\ Users\Admin \Desktop\proj> jar cmf MANIFEST.MF hello.jar com

      第7步:运行它:

      C:\ Users \\ \\ _Admin\Desktop\proj> java -jar hello.jar Infonyx

      详情请见: https://docs.oracle.com/javase/tutorial/deployment/jar/build.html

      请让我知道它的工作原理或不。

      Please let me know it works or not.

      这篇关于创建jar文件的困难的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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