Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Two questions
1) When exporting a java project as a JAR file, how does the application know which Class in the package to run first? My applicatino specifically requires that the userInterface.java file run before the CommonDenom.java file.
2) When running the java file I'm getting an error that says "The Java JAR file "commonDenom.jar" could not be launched. Check the Console for possible messages."
Where do I start to figure this out? I checked the console but it doesn't seem to be registering anything at the time the error message pops.
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 location: /Dropbox/workspace/commonDenom/bin
Class location: /Dropbox/workspace/commonDenom/bin/commonDenom/
Class names:
commonDenom.class
UserInterface.class
UserInterface$1.class (I didn't create this)
UserInterface$2.class (I didn't create this)
Manifest.txt content (with two trailing blank lines):
Main-Class: commonDenom.UserInterface
jar tf CommonDenom.jar returns the following:
META-INF/
META-INF/MANIFEST.MF
Manifest.txt
commonDenom/
commonDenom/commonDenom.class
commonDenom/UserInterface$1.class
commonDenom/UserInterface$2.class
commonDenom/UserInterface.class