|
-
Oct 20th, 2005, 04:42 PM
#1
Thread Starter
Fanatic Member
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.
-
Oct 20th, 2005, 04:51 PM
#2
Fanatic Member
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 
http://www.cs.colostate.edu/helpdocs/JavaInDOS.html
-
Oct 20th, 2005, 06:29 PM
#3
Frenzied Member
Re: Running .jar files in DOS
What do you mean run in dos? Run it from dos?
If so,
java -jar JarFile.jar
-
Oct 20th, 2005, 06:30 PM
#4
Frenzied Member
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.
-
Oct 21st, 2005, 03:46 AM
#5
Thread Starter
Fanatic Member
Re: Running .jar files in DOS
 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.
-
Oct 21st, 2005, 05:04 AM
#6
Frenzied Member
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
-
Oct 21st, 2005, 06:11 AM
#7
Thread Starter
Fanatic Member
Re: Running .jar files in DOS
 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.
-
Oct 22nd, 2005, 07:13 PM
#8
Frenzied Member
Re: Running .jar files in DOS
 Originally Posted by x-ice
I did this, and it works. thanks.
No problem, just glad I was able to help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|