java - 可执行 Jar 文件

标签 java eclipse

如何让该 Java 代码在 Eclipse 之外运行?

import java.util.*; 


public class Calculations {
public static void main(String[] args) {
    Scanner console = new Scanner (System.in); 

    System.out.println("So... you want to figure out what the Hypotenuse of any Right Triangle is but your to");
    System.out.println("lazy to do it your self huh..Sigh... Ok well, At least your being honest about it :)");
    System.out.println();
    System.out.println("Lets do this...Pythagoreom Style");
    System.out.println();
    System.out.println("First things first, whats your Sine? And no I don't mean if your an Aquarious or");
    System.out.print("some shit like that, I mean your Y value or the first side of your triangle?   ");
    double side1 = console.nextDouble();
    System.out.println();
    System.out.println("Okayyyy and now as any good math teacher would say, Whats your Cosine or X value?");
    System.out.print("(You might as well learn some Trigonometry while your taking the easy way out)   ");
    double side2 = console.nextDouble();
    System.out.println();
    System.out.println("Ok give me a minute...  ");
    System.out.println();
    System.out.println();
    System.out.print("Oh, by the way whats your favorite food?   ");
    String x = console.next();
    System.out.println();
    System.out.println();
    double hypotonuse = Math.sqrt((Math.pow(side1,2)+ Math.pow(side2,2))); 
    System.out.println("So you favorite food is " + x + " Huh...well...THATS BESIDES THE POINT!!! BACK TO MATH!!!");
    System.out.println();
    double sum = (Math.pow(side1,2)+Math.pow(side2,2)); 
    System.out.println("So if your First Side is "+side1 + " and we square that and your Second Side is " + side2+ " and we square that too,");
    System.out.println();
    System.out.println("we can add those sides together to get our sum of "+sum+" Finally we can square root "+sum+ " and Viola!");
    System.out.println();
    System.out.println("Pythagoras says your Hypotenuse is "+ hypotonuse);
    System.out.println();
    System.out.println();
    System.out.println("HHHAAAZZZAAAAA!!!! FOR MATH!!! HAAAZZZAAAA for Pythagoreum!!!");
    System.out.println();
    System.out.println();
    System.out.println("Oh, and P.S.");
    System.out.println();
    System.out.println("I'm just kidding, I care about your favorite food,");
    System.out.println();
    System.out.println("Here's a pyramid type thing of it built by a ratio given by your Hypotenuse :)");
    System.out.println();
    System.out.println();
    for( int i =1; i <=hypotonuse; i++)
    { 
        for (int w = 1; w<=(hypotonuse-i); w++)
        {
            System.out.print(" ");
        }

            for(int v=1; v<= (2*i-1); v++)
            {
                System.out.print(" "+ x );
            }

        System.out.println();
    }
}
}

最佳答案

在 Eclipse 中,转到文件>导出>java>可运行的 jar 文件>启动conf 选择主类。导出目的地。导出后文件的目的地>完成

之后,您可以使用命令行运行 jar(这样您就可以看到控制台),在搜索中键入 cmd,然后进入 jar 所在的目录来运行 jar。运行 jar 文件的命令 java - jar名称ofjar.jar

关于java - 可执行 Jar 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21784027/

相关文章:

java - 如何从另一个类中的ArrayList <List> 获取数据?

java - 在 Android 上使用 OpenGL 绘制视频帧

java - 子类化 JButton 以获取有关按钮属性的信息

升级到版本 10.0 后,适用于 Eclipse 的 Android ADT 插件无法正常工作

java - 在 fragment 中,实例不会被保存

eclipse - 在 Eclipse 中导出设置和构建配置

eclipse - Ant "JAVA_HOME does not point to the JDK"- 但确实如此

Java 桶排序

java - 如何使用HTMLUnit登录vbulletin论坛?

eclipse - 以编程方式滚动 NatTable 到选定的行