The Artima Developer Community
Sponsored Link

Java Answers Forum
Dos Prompt

9 replies on 1 page. Most recent reply: Oct 21, 2003 7:10 AM by sabab

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 9 replies on 1 page
sabab

Posts: 34
Nickname: sabab
Registered: Aug, 2003

Dos Prompt Posted: Sep 16, 2003 10:01 AM
Reply to this message Reply
Advertisement
Hai All,

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


pls suggest


Da Killah

Posts: 4
Nickname: dakillah
Registered: Sep, 2003

Re: Dos Prompt Posted: Sep 16, 2003 1:16 PM
Reply to this message Reply
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.

I hope this helps.

zenykx

Posts: 69
Nickname: zenykx
Registered: May, 2003

Re: Dos Prompt Posted: Sep 16, 2003 3:00 PM
Reply to this message Reply
If you really want to have the cmd window disappear use:
start "java" etc or start "javaw" etc.

sabab

Posts: 34
Nickname: sabab
Registered: Aug, 2003

Re: Dos Prompt Posted: Sep 17, 2003 9:32 AM
Reply to this message Reply
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

sabab

Posts: 34
Nickname: sabab
Registered: Aug, 2003

Re: Dos Prompt Posted: Sep 17, 2003 9:54 AM
Reply to this message Reply
i am using a batch file

@echo off
set CURDIR=.;
set ORIGCLASSPATH=%CLASSPATH%
set CLASSPATH=%CURDIR%;%CLASSPATH%

@echo on
java Designs
@echo off

set CLASSPATH=%ORIGCLASSPATH%

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Dos Prompt Posted: Sep 17, 2003 10:23 AM
Reply to this message Reply
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.

Adam Davis

Posts: 2
Nickname: adavis
Registered: Sep, 2003

Re: Dos Prompt Posted: Sep 18, 2003 9:39 AM
Reply to this message Reply
> 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.

zenykx

Posts: 69
Nickname: zenykx
Registered: May, 2003

Re: Dos Prompt Posted: Sep 18, 2003 5:13 PM
Reply to this message Reply
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"

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Dos Prompt Posted: Sep 18, 2003 7:13 PM
Reply to this message Reply
For a graphical program, having the Command Prompt window appear at all, even for a second, looks crappy. Since it is avoidable, why not avoid it?

sabab

Posts: 34
Nickname: sabab
Registered: Aug, 2003

Re: Dos Prompt Posted: Oct 21, 2003 7:10 AM
Reply to this message Reply
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

pls suggest ASAP

Flat View: This topic has 9 replies on 1 page
Topic: JAVA Previous Topic   Next Topic Topic: Problem with selection color JSlider

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use