Is there any way to run Java Clas file without using DOS Prompt.
MY ACTUAL PROBLEM IS: I am executing my class (Designs.class) using a Batch file, so it is opening a DOS prompt before starting the programme, and this DOS prompt will be alive in the background always till i close my application, it is not looking good. And if i try to close this DOS window my entire application is also closing.
Is there any other way to execute class file or is there any solutions to this problem
It depends what tools are you using to develop your Java applications. I think you can create a JAR (Java Archive), which can run directly as an executable file from your Windows Explorer or as a shortcut.
There is a probably a way to create a JAR file from your java files or class files using javac. I'm not sure how though.
If you're using more advanced tools, you can look for the Create Archive or JAR file option.
dear zenykx, I didn't understand what u said, can u please explain in details, suppose my class name is "Designs.class" how will i execute according to ur suggestion
You can't run batch files without running the command interpreter ("dos box"). Even if the batch is only running Windows apps, you will still see the "command prompt" window appear.
What you probably want to do is create a shortcut. That shortcut should use javaw to run your app (class file).
By the way, you can set up [a]all[/a] class files to run automatically when you double-click them, as if they are Windows apps (exe's) -- just associate them with javaw. It is also possible to configure the system to run class files as if they are programs from the command line (for example if you you have created "MyApp.class" all you have to type at the command line is "MyApp" (and whatever parameters)), but that's even more advanced.
> You can't run batch files without running the command > interpreter ("dos box"). Even if the batch is only -snip- > What you probably want to do is create a shortcut. > That shortcut should use javaw to run your app > p (class file). -snip-
For example, I have a shortcut on my (windows) desktop with the following properties:
Target = "C:\Program Files\Java\j2re1.4.0_02\bin\javaw.exe" -cp "C:\java" amd.dailymemo.DailyMemoPad Start in = C:\java Shortcut key = None Run = Normal Window
The -cp option to the java or javaw commands sets the classpath. I'm not sure if you can use the CLASSPATH environment variable like you are in your batch file or not.
Sorry to contra-argue but if inside the bat file you use dos command start you will see the command window just for a fraction of a second. So inside the bat file you must write something like: start "java -cp %YOUR_CLASSPATH% YourClass"
Dear Davis, (After a long silence i am replying to this) yes your sugestion is working fine... ie i created a shortcut like
"c:\JRE\Bin\javaw.exe" -cp "E:\java" Designs
But the problem is , i am distributing this application to different users in my organization and i can't go to each and every one's machine for creating this shourtcut.
So is there any way to create shourtcut in desktop in java, so that i can ask them to run that programe first(one time work) and it wiil create a shourt cut to my main class 'Designs.class' for permanent use