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;
}
}
Re: Running .jar files in DOS
I didn't know java could run in DOS...wouldn't you need a Java interperter for DOS?
Guess I was wrong :p
http://www.cs.colostate.edu/helpdocs/JavaInDOS.html
Re: Running .jar files in DOS
What do you mean run in dos? Run it from dos?
If so,
java -jar JarFile.jar
Re: Running .jar files in DOS
You do have a manifest file in your jar right? You'll need to specify a main-class header.
Re: Running .jar files in DOS
Quote:
Originally Posted by System_Error
You do have a manifest file in your jar right? You'll need to specify a main-class header.
There is no manifest. I compiled the .jar file using BlueJ.
Re: Running .jar files in DOS
Have you tried listing the contents to see if it's there?
I think this lists:
jar tf JarFile.jar
Re: Running .jar files in DOS
Quote:
Originally Posted by System_Error
What do you mean run in dos? Run it from dos?
If so,
java -jar JarFile.jar
I did this, and it works. thanks.
Re: Running .jar files in DOS
Quote:
Originally Posted by x-ice
I did this, and it works. thanks.
No problem, just glad I was able to help ;)