Results 1 to 3 of 3
- 01-31-2010, 03:47 PM #1
Member
- Join Date
- Jan 2010
- Posts
- 8
- Rep Power
- 0
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.
if there is something that i have done that could have been done more efficiently then not my fault im a noob haha :)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(); } }
Thanks in advance.
- 01-31-2010, 06:01 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
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
- 01-31-2010, 06:41 PM #3
Member
- Join Date
- Jan 2010
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
Exporting jar problem
By cocorota in forum EclipseReplies: 0Last Post: 11-20-2009, 05:08 PM -
Problem in running Java swing wizard in jre 1.6 while it is running in jre 1.4
By Sanjay Dwivedi in forum AWT / SwingReplies: 0Last Post: 08-26-2009, 01:03 PM -
Problem when exporting to CSV
By deepusrp in forum New To JavaReplies: 10Last Post: 06-26-2009, 09:33 AM -
Exporting Question
By Moncleared in forum EclipseReplies: 9Last Post: 03-08-2009, 07:35 AM -
Exporting my project
By Nim in forum CLDC and MIDPReplies: 3Last Post: 11-04-2008, 11:53 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks