繁体   English   中英

使用Ecplipse导出时无法使我的程序可执行

[英]Cannot make my program executable when using Ecplipse export

尊敬的Java爱好者,

我想借助eclipse将Java程序制作成可执行的.jar文件。 我已导出到.jar文件,但是双击它似乎不起作用? 我想我缺少了一些东西,但是经过一段时间尝试找到方法后,我找不到了。

有什么建议吗?

import java.util.Scanner;

public class GravityMoon {

public static void main(String[] args) {
            System.out.println("Please enter your earthweight in kilograms below:");

    Scanner earthweight = new Scanner(System.in);
    // Repeat until next item is a double
    while (!earthweight.hasNextDouble()) 
    {        
        // Read and discard offending non-double input
        earthweight.next(); 
        // Re-prompt
        System.out.print("Please enter your earthweight "
                + "in numerical kilograms: "); 
    }

    double moonweight;

    // Converts earthweight in moonweight 17%
    moonweight = earthweight.nextDouble() * 0.17; 

    // convert to whole numbers


    //closes keyboard input
    earthweight.close(); 

    //prints out your moonweight in a decimal number
    System.out.println("Your moonweight is " + Math.round(moonweight * 100d) /100d 
            + " kilograms.");

        }}

因为您没有解释确切的问题,所以我可能仅给出提示:

  1. 导出为可执行Jar

    在Eclipse中,可以选择导出到jar文件中,还可以选择导出到可执行jar文件中(请参阅http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt。 doc.user%2Ftasks%2Ftasks-37.htm )。

  2. (我猜您正在使用Windows)尝试从控制台执行jar文件(类似于java -jar)。

    双击Windows中的jar文件不会打开终端窗口。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM