gpt4 book ai didi

java - 可执行 Jar 文件

转载 作者:行者123 更新时间:2023-12-01 13:26:42 26 4
gpt4 key购买 nike

如何让该 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com