Results 1 to 8 of 8

Thread: Running .jar files in DOS

Threaded View

  1. #1

    Thread Starter
    Fanatic Member x-ice's Avatar
    Join Date
    Mar 2004
    Location
    UK
    Posts
    671

    Resolved Running .jar files in DOS

    I have made a .jar file that is supposed to run in DOS, but when i execute it (through DOS) nothing happens. How can i get it to run in DOS? If it is any help here is my code.
    Code:
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    
    public class Student
    {
    
      	private static String Teacher;
    	private static String StudentName;
    
    	/**
    	 * Create a student
    	 *
    	 * @param StudentName
    	 */
    	public Student()
    	{
    		//Do nothing!
    	}
    	
    	public static void main(String[] args)
    	{
    	    Student student = new Student();
    	    	    
    	    Teacher = "Mr Whyley";
    	    StudentName = getUserInput();
    	    //Print details
            System.out.println("Student Name: " + StudentName);
            System.out.println("Teacher: " + Teacher);
    	}
    
    	/**
    	 * Get teacher name for a student
    	 * 
    	 * @return Teacher
    	 */
    	public String getTeacher()
    	{
    		return Teacher;
    	}
    	
    	public static String getUserInput()
    	{
    	    String StuName = "Unknown";
    	    //Print the message
    	    System.out.print("What is the student name? ");
    	    //The input reader
    	    BufferedReader UsrInput = new BufferedReader(new InputStreamReader(System.in));
    	    try
    	    {
    	        //Assign user input to the buffered reader
    	        StuName = UsrInput.readLine();
    	    }
    	    catch(java.io.IOException Ex) 
    	    {
                System.out.println ("An error has occured: " + Ex.getMessage());
            }
            System.out.println(); //Blank line;
            //Return user input
    	    return StuName;
    	 }
    	   
    }
    Last edited by x-ice; Feb 25th, 2007 at 07:17 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width