Question:
how do i use command prompt to compile and run JAVA programs?
quest
2008-07-21 00:06:31 UTC
do i need to download a compiler like the JSDK
for running java programs ?
Three answers:
Mani
2008-07-21 00:18:35 UTC
You want compile and execute java application, need to install jdk. you can download it from java.sun.com.



once you installed you have setup the enthronement details. PATH and CLASSPATH



Refer this steps:



Setting Up Your Java Environment



After installing the Java SDK as described in the section JavaTM2 Software Development Kit, your only remaining task is to set the value for JAVA_HOME and update the PATH environment variable.



JAVA_HOME must point to the directory where you installed the SDK and PATH must point to the bin subdirectory of the SDK. Here are examples for the Unix and Windows platforms:



Unix platforms



*



Assuming that you installed the SDK in the /usr/local/jdk1.3.1 directory, you should enter the following:



bash>export JAVA_HOME=/usr/local/jdk1.3.1



or



tcsh>setenv JAVA_HOME /usr/local/jdk1.3.1



*



You then have to update your PATH variable by appending /usr/local/jdk1.3.1/bin. If JAVA_HOME has been properly set, you can proceed as follows:



bash>export PATH=${PATH}:${JAVA_HOME}/bin



or



tcsh>setenv PATH ${PATH}:${JAVA_HOME}/bin



Note



Environment variables must be correctly set at all times. It is common practice to insert these commands in your shell start file (.bashrc, .cshrc, ...).



Windows platforms



*



Assuming that you installed the SDK in the C:\jdk1.3.1 directory, you can issue the following command:



C:>set JAVA_HOME=C:\jdk1.3.1



*



You then have to update your PATH variable by appending C:\jdk1.3.1\bin. If JAVA_HOME has been properly set, you can enter the following:



C:>set PATH=%PATH%;%JAVA_HOME%\bin



To update the path permanently, do the following depending upon your Windows version:



Windows 95 or 98



You must insert this command in the AUTOEXEC.BAT file.



Windows Me



Go to the Start Menu, then choose Programs, Accessories, System Tools and System Information. A window titled "Microsoft Help and Support" should appear. Select the Tools menu, and choose the System Configuration Utility. Go to the Environment tab where you can edit the PATH variable. Append the value ;C:\jdk1.3.1\bin. Once you have changed and saved the value, you will be prompted to reboot.



Windows NT



Go to the Start Menu, then choose Settings, Control Panel and select System. Select the Environment tab and look User Variables and System Variables for PATH. Then edit the value and append the value ;C:\jdk1.3.1\bin.



Windows 2000



Go to the Start Menu, then choose Settings, Control Panel and select the System icon. Select the Advanced tab and then click on the Environment Variables button and then edit the System Variables entries for PATH by appending ;C:\jdk1.3.1\bin.



Windows XP



Go to the Start Menu, then double click on System. In the System Control Panel select the Advanced tab and push the Environment Variables button. Now, you can look for the PATH to edit. Append the value ;C:\jdk1.3.1\bin. Once you have changed and saved the value, you will be prompted to reboot.
Punit
2008-07-21 07:16:21 UTC
Yes buddy, you need JDK for creating JAVA programs.



after that, you will be able to compile, execute your programs using commands java, javac etc.



Get JDK from:

http://download.java.net/jdk6/
anonymous
2008-07-21 07:46:05 UTC
javac [ options ] [ sourcefiles ] [ @argfiles ]



If you don't like to write all this things you can use Ant or Maven. They are well automated in Netbeans or Eclipse.


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