java -jar 出错_Java导出为Jar时出错

两个问题

1)将Java项目导出为JAR文件时,应用程序如何知道包中的哪个类首先运行?我的applicatino特别要求userInterface.java文件在CommonDenom.java文件之前运行。

2)运行Java文件时,出现错误消息“无法启动Java JAR文件“ commonDenom.jar”。请在控制台中查看可能的消息。”

我从哪里开始弄清楚这一点?我检查了控制台,但弹出错误消息时似乎没有注册任何东西。

package commonDenom;

import java.util.Arrays;

import java.util.Scanner;

import org.eclipse.swt.SWT;

import org.eclipse.swt.events.SelectionAdapter;

import org.eclipse.swt.events.SelectionEvent;

import org.eclipse.swt.widgets.Button;

import org.eclipse.swt.widgets.Display;

import org.eclipse.swt.widgets.Shell;

import org.eclipse.swt.widgets.Text;

public class UserInterface {

Shell shell;

Button btnNext;

Button btnDone;

Text input;

Text output;

static int count;

static int[] finalNums;

int[] nums = new int[1000];

public static void main(String[] args){

Display display = new Display();

new UserInterface(display);

display.dispose();

}

public UserInterface(Display display){

shell = new Shell(display);

shell.setSize(220,350);

shell.open();

input = new Text(shell, SWT.SINGLE);

input.setBounds(10, 10, 100, 20);

btnNext = new Button(shell, SWT.PUSH);

btnNext.setBounds(10, 40, 100, 30);

btnNext.setText("Next");

nextPress();

btnDone = new Button(shell, SWT.PUSH);

btnDone.setBounds(10, 80, 100, 30);

btnDone.setText("Done");

donePress();

output = new Text(shell, SWT.SINGLE);

output.setBounds(10, 120, 200, 200);

while(!shell.isDisposed()){

if(!display.readAndDispatch()){

display.sleep();

}

}

}

public void nextPress(){

btnNext.addSelectionListener(new SelectionAdapter(){

int x = 0;

@Override

public void widgetSelected(SelectionEvent e) {

nums[x] = Integer.parseInt(input.getText());

System.out.println("nums[" + x + "]:" + nums[x]);

x++;

count++;

}

});

}

public void donePress(){

btnDone.addSelectionListener(new SelectionAdapter(){

@Override

public void widgetSelected(SelectionEvent e) {

finalNums = new int[count];

for(int i = 0; i < count; i++){

finalNums[i] = nums[i];

}

System.out.println("finalNums:" + Arrays.toString(finalNums));

commonDenom.compare();

if(commonDenom.getResult() == 0){

output.setText(Arrays.toString(finalNums) + "\nThese numbers do not have a \ncommon multiplier");

}

else{

output.setText(Arrays.toString(finalNums) + "\nResult:" + String.valueOf(commonDenom.getResult()));

}

}

});

}

public static int[] getNums(){

return finalNums;

}

}

Manifest.txt位置:/ Dropbox / workspace / commonDenom / bin

类位置:/ Dropbox / workspace / commonDenom / bin / commonDenom /

类名:

commonDenom.class

UserInterface.class

UserInterface$1.class (I didn't create this)

UserInterface$2.class (I didn't create this)

Manifest.txt内容(两个空白行):

Main-Class: commonDenom.UserInterface

jar tf CommonDenom.jar返回以下内容:

META-INF/

META-INF/MANIFEST.MF

Manifest.txt

commonDenom/

commonDenom/commonDenom.class

commonDenom/UserInterface$1.class

commonDenom/UserInterface$2.class

commonDenom/UserInterface.class

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值