This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple Compiling Question

 
Daniel Foreacre
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there, I figured I'd come here for a bit of help, and probably stick around for a while. I've been learning programming for about 6 years now, first BASIC, then C++, and now Java. I wouldn't exactly call myself a beginner in the concepts involved, but there's a lot of the 'basic' stuff I've been exposed to recently. I was writing Java programs before on a Linux machine, compiling and executing through the terminal. Although it was different than how I coded before (through Borland C++), it wasn't too difficult. Now I'm trying to code on my PC through the MS-DOS prompt. I found the java command to execute, but how do I compile my program? There isn't any javac command. I'm using the Java 1.4 SDK. Any help/tips would be appreciated
Dan
 
Peter Wong
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you say this command :
c:\path of jdk\bin\> javac yourprogram.java
 
Daniel Foreacre
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it have to be in the java sdk directory? I've got a program now just in C:\, for the sake of simplicity. ">javac Test.java" did SOMETHING, but then "java Test" brought up the "exception in thread "main" java.lang.NoClassDefFoundError: Test" error, which I assume means it wasn't compiled.... right?
Dan
 
Peter Wong
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your program run "main" ?
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
make sure that your program has a properly formatted main method:
public static void main(String[] args) {
}
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NoClassDefFoundError is usually a problem with the classpath.

What is your classpath? Does it point to the subdir where the compiled Test.class can be found?
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel, a good place to start is here: Suns's Instructions
If something fails, let us know and we will try to help you fix it.
 
Daniel Foreacre
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the link to Sun. Turns out the path for javac wasn't set right. It's compiling now
Dan
 
Daniel Foreacre
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That error message was generated when I tried executing Test, but since it wasn't compiled it wouldn't do anything (I think).
Dan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic