Results 1 to 3 of 3
  1. #1
    JonnySnip3r is offline Member
    Join Date
    Jan 2010
    Posts
    8
    Rep Power
    0

    Default Exporting to JAR and running in cmd

    Hey guys i have just created a program in eclipse to calculate UCAS points as i am going to uni this year and had nothing else to do today haha :)

    Anyways one things i have never learned to do in java (btw i am a noob only been learning for a few weeks) is export as JAR and be able to run it in command prompt.

    I can get the thing to run in cmd if i compile it using command prompt or in eclipse when i debug it everything works fine however when i run the finished JAR file on windows nothing happens :( do i need to import something or am i doing it wrong?

    here is the source for my application.

    Java Code:
    import java.util.Scanner;
    import java.io.*;
    
    public class ucasCalc {
    	public static void main(String[] args) throws IOException{
    		
    		int totalUCAS = 0;
    		char grade;
    		int counter = 0;
    		int howMany; // Stores the amount of grades.
    		
    		char CharP = 6;
    		char CharM = 12;
    		char CharD = 18;
    		
    		System.out.print("Please enter how many grades you need me to calculate: ");
    		Scanner input = new Scanner(System.in);
    		howMany = input.nextInt();
    		
    		System.out.println("I will now calculate " + howMany);
    		System.out.println("D = 18, M = 12, P = 6");
    		
    		while (counter < howMany) {
    			System.out.print("Please enter grade (eg D,M,P): ");
    			grade = input.next().charAt(0);
    			
    			if (grade == 'D') {
    				totalUCAS = totalUCAS + CharD;
    			}
    			
    			if (grade == 'M'){
    				totalUCAS = totalUCAS + CharM;
    			}
    			
    			if (grade == 'P'){
    				totalUCAS = totalUCAS + CharP;
    			}
    			
    			counter++;
    		}
    		
    		System.out.println("Your overall UCAS points are: " + totalUCAS);
    		
    		File someFile = new File("UCAS_POINTS.txt");
    		
    		BufferedWriter output = new BufferedWriter(new FileWriter(someFile));
    		
    		output.write("Program created by John :) You have " + totalUCAS + " points.");
    		
    		output.close();
    		
    	}
    
    }
    if there is something that i have done that could have been done more efficiently then not my fault im a noob haha :)

    Thanks in advance.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,351
    Blog Entries
    7
    Rep Power
    20

    Default

    I see a bunch of Sytem.out.println( ... ) calls so you can't use javaw.exe for it because that version of the jvm doesn't fire up a console for you. What are you using for your command line?

    kind regards,

    Jos

  3. #3
    JonnySnip3r is offline Member
    Join Date
    Jan 2010
    Posts
    8
    Rep Power
    0

    Default

    Hey dude im using command prompt in windows. is there any other way you suggest?

    Thanks :)

Similar Threads

  1. Exporting jar problem
    By cocorota in forum Eclipse
    Replies: 0
    Last Post: 11-20-2009, 05:08 PM
  2. Replies: 0
    Last Post: 08-26-2009, 01:03 PM
  3. Problem when exporting to CSV
    By deepusrp in forum New To Java
    Replies: 10
    Last Post: 06-26-2009, 09:33 AM
  4. Exporting Question
    By Moncleared in forum Eclipse
    Replies: 9
    Last Post: 03-08-2009, 07:35 AM
  5. Exporting my project
    By Nim in forum CLDC and MIDP
    Replies: 3
    Last Post: 11-04-2008, 11:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •