ok
before you can run your program written with java by a batch file you need to know how batch file work
i will assume that you don't know
batch file is a kind of file that group a number of dos command to be execute as a program
most of dos command can be used to write a batch file and there are a number of command can be used in batch file but not in dos
------------------------------------------------------------------------
in jdk there are to executable file called java and javac
you know that javac is used to call compiler to compile your files (class) and the file java is used to call the executer to execute your file ( executable class wich contain main method )
i read that you have installed jcreator
in jcreator configuration when you used it(jcreator) to the first time the jcreator asked you to define the location of jdk
he didn't ask you that for nothing
but he asked you that to use the 2 files ( javac and java )
but to dos or batch file those to file are not registerd then if you write javac or java in dos an error occure
for that you need to register those two files to be known by cmd or batch file
to register them if you are using windows Os ( winxp sp1, sp2, or other )
first go to the location where you have installed you jdk by default it's :
C:\Program Files\Java\jdk<<
>\bin
note it's important to include the name of the folder that contain java and javac ((called Bin))
example :
C:\Program Files\Java\jdk1.5.0\bin
copy this address
Second:
go to :
1- right click mycomputer
2- choose properties
3- choose the Advanced
4-environment variables
5- a window appear go to the System variables
6-in the scroll box choose path ( vaiable )
7- click Edit
8-at the end of variable value textbox text write semicolon (;)
9-paste the address that you have copy
10-write a semicolon (;)
you have now registerd all executable file in the bin folder and the most important two file are ( java and javac)
now you can write in dos (cmd ) java to execute file but you need to give all tha address of the location of the class
example :
java c:\prog\test
not test is class file but when you use java (command ) don't wirte the extension .class
if you want simply to write java test
you need to tell the system where the file test (class ) exesit
you can do that doing those steps :
1- right click mycomputer
2- choose properties
3- choose the Advanced
4-environment variables
5- a window appear go to the System variables
6-in the scroll box choose CLASSPATH (vaiable )
( if it doesn't existe create it by click new
in variable name write CLASSPATH
in variable value paste the address of the location of the executable class file that you want to execute for example
c:\pro;
)
7- click Edit
8-at the end of variable value textbox text write semicolon (;)
9-paste the address of the file
10-write a semicolon (;)
now you have finished all resitration of variable needed by the system
----------------------------------------------
now you can creat the batch file
go to notepad
write
java <>
note : again don't write the extension .class
click file save
file type write bat
save it
now you have you batch file that execute your file
with my respect