Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 615 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to run Java application by .bat file

#1
I need to run my Java Application through a .bat file.
Reply

#2
Call the class which has main() method.

`java MyClass`

Here MyClass will have `public static void main()` method.
Reply

#3
Simply create a .bat file with the following lines in it:

@ECHO OFF
set CLASSPATH=.
set CLASSPATH=%CLASSPATH%;path/to/needed/jars/my.jar

%JAVA_HOME%\bin\java -Xms128m -Xmx384m -Xnoclassgc ro.my.class.MyClass
Reply

#4
If You have jar file then create bat file with:

java -jar NameOfJar.jar
Reply

#5
@echo off
echo You Are going to creata Java Class
set /p Name=Enter your Class Name?:
echo Your class Name is %Name% & pause
echo To creat a Notepad
pause
notepad %Name%.java
set path=%PATH%;C:\Program Files\Java\jdk1.6.0_14\bin
pause
javac
echo Your java Path succsussfully set.
javac %Name%.java
pause
echo Successfully Compiled
java %Name%
pause

1)open a notpad
2)copy and past this code and save this file as <name.bat>
ex: test.bat
3)Double Click tha batch file.
4)put your java codes into the notepad and save it as <your_java_class_name.java>
N.B.:- save this java file same folder that your batch file exists.
Reply

#6
`javac Application.java`

`java Application`

`pause`

The `javac` command will compile the java program and the `java` command will run the program and `pause` will pause the result until you cross it.
Reply

#7
It's the same way you run it from command line. Just put that "command line" into a ".bat" file.

So, if you use `java -cp .;foo.jar Bar`, put that into a .bat file as

@echo off

java -cp .;foo.jar Bar
Reply

#8
Sure, call the java executable.

Mine is `C:\Program Files\Java\jre6\bin\java.exe`, so to run it I would do

`C:\Program Files\Java\jre6\bin\java.exe -jar myjarfile.jar`
Reply

#9
- javac (.exe on Windows) binary path must be added into global PATH env. variable.

javac MyProgram.java

- or with java (.exe on Windows).

java MyProgram.jar
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through