Question:
after i compile my java file how do i tun the class file?
?
2010-12-19 22:00:33 UTC
well someone helped me fixing my other errors but now how do i run the .class file or how do i convert it to a .exe file? please i rather convert it to .exe but how?
Five answers:
auddrey_nw
2010-12-19 22:13:47 UTC
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 JDK’s 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
?
2010-12-19 22:09:36 UTC
If you are using jdk1.2... then write a program and compile as follows:-

javac a.java

java a this will run .class file and run java file and if you are using Bluj then do the following



compile the code if error freee then go to file and right click on that then run program that will execute java file.
2016-12-02 10:45:14 UTC
The .java record is what you will enter in NetBeans. that's going to produce the .classification records while it compiles. you ought to be waiting to run the .classification records that have a considerable() approach from in the NetBeans IDE.
Stacey R
2010-12-19 22:09:31 UTC
Save the file with a .java extension.

Then compile the file in cmd using "javac filename.java"

and execute it with "java filename"
Gardner
2010-12-19 22:09:52 UTC
You do realize that DDoS attacks are illegal right?


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...