Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-25-2007, 06:18 PM
Member
 
Join Date: Jul 2007
Posts: 10
specbailey is on a distinguished road
just starting
I am just starting to learn java, I have some programs coded, but when I enter javac into the command prompt, it gives me an error saying "javac is not recognized as an internal or external command, operable program or batch file." I adjusted my environment variables (class path & path), but still no luck. What do I need to configure to get this to work?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-25-2007, 08:29 PM
Member
 
Join Date: Jul 2007
Posts: 55
Seemster is on a distinguished road
Add the location of your java home to your path. Try running java -version from the command prompt. I'm thinking it'll throw an error. Once you've defined the entry correctly, the above command should work.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-25-2007, 08:41 PM
Member
 
Join Date: Jul 2007
Posts: 10
specbailey is on a distinguished road
when i type in java -version it comes back fine, with a version of 1.6.0_01. what is the java home path location?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-25-2007, 09:29 PM
Member
 
Join Date: Jul 2007
Posts: 10
specbailey is on a distinguished road
ok, i added the java path location, now I can compile the program but can't run it. I get an error that says "Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld"

How do I fix this?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-25-2007, 09:52 PM
Member
 
Join Date: Jul 2007
Posts: 55
Seemster is on a distinguished road
are you running the javac from the same directory the program is in? you can supply classpath information by:

javac -cp <classpath>
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-25-2007, 10:25 PM
Member
 
Join Date: Jul 2007
Posts: 10
specbailey is on a distinguished road
yes, I'm running it from the folder that my program is saved on. but still getting the same error message
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 07-25-2007, 10:39 PM
Member
 
Join Date: Jul 2007
Posts: 55
Seemster is on a distinguished road
Can you post the exact command your using to execute the code.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 07-25-2007, 11:02 PM
Member
 
Join Date: Jul 2007
Posts: 10
specbailey is on a distinguished road
in the directory that my program is saved in I type:
javac HelloWorld.java

that comes back fine, and a HelloWorld.class file is created
then I type:
java HelloWorld

and then i receive the error:
"Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld"
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 07-25-2007, 11:08 PM
Member
 
Join Date: Jul 2007
Posts: 55
Seemster is on a distinguished road
I don't know what your doing wrong. I just wrote a quick class to that. From the command prompt where your file is at:

1. javac HelloWorld.java
2. java HelloWorld

HelloWorld.java:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}

>>>>>>>>>>>>>>>>>>>>>>
output
>>>>>>>>>>>>>>>>>>>>>>
HelloWorld
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 07-25-2007, 11:42 PM
Member
 
Join Date: Jul 2007
Posts: 10
specbailey is on a distinguished road
the only thing i can think of are the environment variables, but i've tried changing them, with no luck.
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 07-26-2007, 07:49 PM
Senior Member
 
Join Date: Dec 2006
Posts: 748
levent is on a distinguished road
specbailey: Working with classpath is not easy. You will need to practice about it. There are several resources to read for learning managing classpath.

But alternatively you can try to use an IDE (Eclipse or Netbeans) which will make the classpath management intuitive.
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 08-10-2007, 03:27 AM
Member
 
Join Date: Jul 2007
Posts: 10
specbailey is on a distinguished road
I am still having the same problems. I cannot compile programs or execute them. I have checked the path and the classpath. What else do I need to do to run java programs?
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 08-10-2007, 03:52 AM
Member
 
Join Date: Jul 2007
Posts: 10
specbailey is on a distinguished road
when I type javac HelloWorld.java I get an error that says:
'javac' is not recognized as an internal or external command, operable program or batch file.

which means that it will not compile so I cannot go on from there.

When I type java -version i get:
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 08-10-2007, 10:20 AM
Member
 
Join Date: Aug 2007
Posts: 2
vibhor.ec is on a distinguished road
do 1 thing,just save ur programm in bin folder in ur jdk directory and then simply compile it.........javac HelloWorld.java

else tell me ur full path of java directory
Bookmark Post in Technorati
Reply With Quote
  #15 (permalink)  
Old 08-10-2007, 06:33 PM
Member
 
Join Date: Aug 2007
Posts: 5
Neon Blue is on a distinguished road
specbailey,
Thank you for your post. It sounds as though you and I are having the same kind of problems. I infer that you are using Java 2 SDK 1.6.x.x. Is the OS WinXP? and you are trying to compile and run a "Hello World" program from Command Prompt.

The error message you get when you try javac Hello World.java is the same as I get.

So when I try to configure SDK 1.3.1_20 according to the text I am reading I need to find a file AUTOEXEC.BAT, which I cannot. Apparently the OS in play when the book was published was 2000 and NT. Not being a Windows user I asked another forum about this file and was directed to a MS instruction page where I learn that the variables once maintained by AUTOEXEC.BAT are now maintained by the Registry in XP. Going to My Computer, as you did, I found the editing feature for environmental variables under Propeerties, but I do not know what information to add so as to point to PATH and CLASSPATH for Java. What entrys did you make?

Thanks
Bookmark Post in Technorati
Reply With Quote
  #16 (permalink)  
Old 08-10-2007, 08:00 PM
Member
 
Join Date: Aug 2007
Posts: 2
Vengeance45 is on a distinguished road
Spec, can you copy your code in? Wondering if you have declared a package.
Bookmark Post in Technorati
Reply With Quote
  #17 (permalink)  
Old 08-11-2007, 05:02 PM
Member
 
Join Date: Jul 2007
Posts: 23
marco is on a distinguished road
its not a problem with the code, in cmd u were passing arguments wrong, what i did was just right clicked on the .java and selected "open with" and opened it with javac.exe, i would also recommend downloading JKD 6.0 or higher and running it with the javac.exe in the JDK bin
Bookmark Post in Technorati
Reply With Quote
  #18 (permalink)  
Old 08-12-2007, 08:49 PM
Member
 
Join Date: Jul 2007
Posts: 10
specbailey is on a distinguished road
I copied my .java file into the bin folder, now I am able to compile the program and there is a .class created, but now I can't execute the program by typing:
java HelloWorld

I get an error that says:
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/class

even though it compiled ok.
Bookmark Post in Technorati
Reply With Quote
  #19 (permalink)  
Old 08-13-2007, 02:52 AM
Member
 
Join Date: Jul 2007
Posts: 23
marco is on a distinguished road
what type of template is the program? hsa, applet, application?
Bookmark Post in Technorati
Reply With Quote
  #20 (permalink)  
Old 08-13-2007, 05:33 AM
Member
 
Join Date: Jul 2007
Posts: 10
specbailey is on a distinguished road
I don't know what template the program is... here is the code:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Indexing starting with 1 ravian New To Java 4 01-04-2008 01:03 PM
Help, starting with java mathias New To Java 2 08-15-2007 08:15 AM


All times are GMT +3. The time now is 03:12 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org