Question:
how can I compile a java program?
behy b
2006-12-17 21:30:18 UTC
I download a compiler but I can't compile my java program
Six answers:
?
2006-12-18 04:49:48 UTC
ok try this. this may help you



start -->run --> notepad autoexec.bat(type this)



a notepad file opens and append the below lines in that file



set path=drive\java directory\bin;%path%;

set classpath=drive\java directory\lib\tools.jar;dirve\java directory\bin;%classpath%;



here drive means the local drive in which java is installed

java directory means the name of the folder in which java is installed



after editing this file save it..



now go to start --> run --> cmd(type)



a window with black background appears



type this in that window



c:autoexec.bat



after typing this type the below one too



javac drive\directory\ your java file.java



here drive is in which local dirve your file or folder is but if u save your file directly in local drive type this



javac drive(your local drive)\you file name.java



but if u saved it in a folder type this



javac drive\directory\ your java file.java



where directory is in which your java file is



am sure this will help you..........



u can meet me online for more answer my yahoo ID is rgunday@yahoo.com
Somnath M
2006-12-17 23:00:13 UTC
I suppose you hvae downloaded and installed the JAVA SDK then to the following steps.



1. See "My Computer Property"

> Go to Advanced Tab

> click on the environment variables

> In System variables , Select "Path"



( Suppose you have J2SDK in the C:\Program Files\Java\j2re1.4.2_13 folder then your Bin folder ( that contains the actuak compiler files ) )

- Select "Path" click "edit"

- Add the string ;C:\Program Files\Java\j2re1.4.2_13\bin ( in your case path may be different ) at the end of the Path value

*** NOTE the semicolon in before the string ( ; )



- Click OK



2. Your program should compile well now

a. command promt

b. CD c:\test (here go to your folder)

c. javac test.java ( this should compile your java program )
2016-05-23 07:38:31 UTC
You need the Java runtime (JRE) to be installed on the computer, no matter what. That has just the files needed to run Java. You can test that in advance. Fire up the command prompt on the computer you want to use, and then enter: java -version If you get a response like: java version "1.7.0_21" Java(TM) SE Runtime Environment (build 1.7.0_21-b11) Java HotSpot(TM) Client VM (build 23.21-b01, mixed mode, sharing) ...then you have Java installed and know the version. If you get a message like "'java' is not recognized as an internal or external command, operable program or batch file." then Java is either not installed or not installed properly. You don't need the Java Development Kit (JDK) and you don't need NetBeans, Eclipse or any other development tools. All you need is the class files, possibly packed into a JAR file. If you're just running from the command line, copy *.class from your working directory to the the USB drive. If you are compiling with NetBeans or Eclipse, either of those automatically pack everything the app needs into a JAR file. In NetBeans, it's stored in the "dist" subdirectory as "yourprojectname.jar". Just copy that to where you need it. With Eclipse, use the File>Export... and specify "Java>JAR File" in the window under "Export Destination" and click Next. Under "Export destination", click "Browse...", navigate to the folder where you want to put the JAR file, type a name with a .jar extension in the file name box (won't exist the first time), like "MyApp.jar" or something, and then click Finish. Since you have a console program, odds are that Windows is not set up to run a JAR or Java .class file with a console. You need to add one little bit to make it "clickable". A three line batch file, maybe named "MyApp.bat". Running from .class files, it will look like: @echo off java MyMainClass %* pause Running from a JAR file: @echo off java -jar MyApp.jar %* pause Now you should be able to just double-click on the batch file. The pause command will keep the screen from closing at the end of the run, prompting you to press a key first. Maybe your app doesn't need that, but it's a nice bit to have if you have an unexpected problem. You'll get to see and maybe copy/paste the exception message for debugging.
jaden404
2006-12-17 21:34:00 UTC
I am assuming that you have installed JDK 1.5?



What error message do you get?

What compiler are you using?
2006-12-17 21:34:53 UTC
use a program like JCreator...also u will need to have JDK installed...
howsureyouare
2006-12-17 23:04:26 UTC
javac -classpath %classpath% Myclass.java


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