to run your class file follow the follwing :
Run Command Prompt (found under All Programs/Accessories in the Start menu). Type /OR [[press(windows key of your keybord+r)-> type run]
For example the class file is in a directory named “mywork” in c drive and the java file name is HelloWorld.java
C:\> cd \mywork
This makes C:\mywork the current directory.
C:\mywork> dir
This displays the directory contents. You should see HelloWorld.java among the files.
C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
This tells the system where to find JDK programs.may be it different on your system; put yours one
C:\mywork> javac HelloWorld.java
This runs javac.exe, the compiler. You should see nothing but the next system prompt...
C:\mywork> dir
javac has created the HelloWorld.class file. You should see HelloWorld.java andHelloWorld.class among the files.
C:\mywork> java HelloWorld
and for exe file you need to make a jar. do you need that or the above is enough ?
Thank you for your message
---------------------------------------
hey well yah i know how to compile it but when i try to execute the.class file it says "windows cant open this file" for example iff your trying to run a .2k file that type of error or ppt it will open a list of programs you can try using to open an view it but also if you could please tell me how to convert it to exe so my questions were
(1) what do i do when i try running the .class file an it says windows cant open file an i have to pick something from list of programs?
My Answer:
are you trying to double click over .class file ? if not the following should help you
1. on cmd go to the folder that contains the.class folder
like
C> cd mywork
2. run file {just type java and then only the file name without .class}for example
c:\mywork> java HelloWorld
2.In java there .exe is similar to .jar which is executable file go through the following example please
Creating a jar File in Command Prompt
Start Command Prompt.
Navigate to the folder that holds your class files:
C:\>cd \mywork
Set path to include JDKs bin. For example:
C:\mywork> path c:\Program Files\Java\jdk1.5.0_09\bin;%path%
Compile your class(es):
C:\mywork> javac *.java
Create a manifest file:
C:\mywork> echo Main-Class: DanceStudio >manifest.txt
Create a jar file:
C:\mywork> jar cvfm DanceStudio.jar manifest.txt *.class
Test your jar:
C:\mywork> DanceStudio.jar
I hope this will help you. Cheers