Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Compile and execute a program in java

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 03-03-2010
Member
 
Join Date: Dec 2009
Posts: 202
Compile and execute a program in java
  

Hello,
I am a beginner please how I can compile and execute a small program like this under windows:
Code:
class HelloWorld
    {
    Public static void hand(String[ ] args)
        {
        System.out.printl("Hello World!"); / / Displays the string
        }
    }
Any help will be highly appreciated. Thanks in advance.

Reply With Quote
  #2  
Old 03-03-2010
Member
 
Join Date: Nov 2009
Posts: 356
Re: Compile and execute a program in java

Hello,
I recommend you to take a tutorial on the core java, so that you can understand the basic of the programming language.
Still, for information you need to do a file "<filename>. Java"
The compile command line "javac <filename>. Java"
And finally, run by "java <filename>.
Once you feel comfortable in command line you can switch to the IDE like Eclipse and code your programs there.
Reply With Quote
  #3  
Old 03-03-2010
Member
 
Join Date: Nov 2008
Posts: 240
Re: Compile and execute a program in java

Hello,
Even I am very new to this programming language (java), I tried what you have said in your above post. When I made javac <file_name>. java it replied:
"javac" is not recognized as internal or external, operable program or batch file.
What exactly is this error about, what I have to do to eliminate this error and get my first java program running. Thanks in advance.
Reply With Quote
  #4  
Old 03-03-2010
Member
 
Join Date: Nov 2009
Posts: 343
Re: Compile and execute a program in java

Hello,
Code:
"javac" is not recognized as internal or external, operable program or batch file.
You are getting this error because you have not defined the path correctly. Add the executable directory in the PATH variable in your operating system
example
Code:
Windows: PATH =% PATH% c: \ program file \ jdk1.6.0 \ bin
Linux: export PATH = $ (PATH): / usr/bin/jdk1.6.0/bin
Hope you will change your path to the correct directory that you are working in.
Reply With Quote
  #5  
Old 03-03-2010
Member
 
Join Date: Dec 2009
Posts: 202
Re: Compile and execute a program in java

Hello,
Even I get a similar kind of a error while running the program.
I try to do java <file_name>. java I generate this error:
Code:
Exception in thread "main" java.lang.NoClassDefFoundError:
and when I made javac it said:
Code:
"javac" is recognized as internal or external, operable program or batch file.
Do you have a solution for this, if then please let me know I am waiting for it.
Reply With Quote
  #6  
Old 03-03-2010
Member
 
Join Date: Nov 2009
Posts: 583
Re: Compile and execute a program in java

Hello,
You do right click on desktop-> Properties -> Advanced (or tab style)
Variable System -> select the variable Path and click Edit. You then added
Code:
c: \ program file \ jdk1.6.0 \ bin
or the path where your JDK is installed. You valid and you reopen an MS-DOS window to restart the comp. This will set your path and you are ready for compiling and running that is executing the program. Best of Luck.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Compile and execute a program in java"
Thread Thread Starter Forum Replies Last Post
How to compile program for PowerPC Ubuntu? Dipanwita Operating Systems 1 24-01-2012 06:09 AM
Compile java program from mobile Maya Angelou Software Development 4 01-04-2010 09:15 AM
Unable to compile and execute code spuff Software Development 5 24-12-2009 01:56 PM
Problem to compile a program under linux Xmen Software Development 5 19-12-2009 10:29 AM
how to execute C#.NET program? ruby1234 Software Development 2 19-11-2008 02:24 PM


All times are GMT +5.5. The time now is 07:10 PM.