i want to call the java class in batch file. how can i call. can tell me any commands which call the class file
Thanks Krishna
i want to call the java class in batch file. how can i call. can tell me any commands which call the class file
Thanks Krishna
You can do the following:
Write the following lines of code, then saves it as "MyFile.bat" (Note we are saving as BAT File.
@ECHO OFF
javac YourClass.java
java YourClass
Now double click the BAT file to run, it should execute your java program.
Note: The BAT file and Java Class should be in the same directory.
@echo off
java -jar "C:\path_to_jar_directory\test.jar" "C:\path_to_arguments\property.properties"
If you have compiled your
.java
file, and have the.class
file, containing bytecode for yourmain
function, then just run:where
myclass
is the module name (file has to bemyclass.class
).if you are having a class Myclass with package name com.mycomp.util then you have to go to the parent dir of "com" for example "c:\src" is the folder that contains com package then
your command should be in the batch file
cd c:\src java -cp jar1;jar2; com.mycomp.util.Myclass
now call the batch file.
Just use this in ur .bat file
java -classpath folderName/example.jar; com.example.package.ExampleProgram
if you are placing the .bat file in the same folder with the jar, then its not necessary to mention the folderNameI would recommend first jaring up your class(es) and providing a link to the jar.