aspose file tools*
The moose likes Beginning Java and the fly likes Simple Compiling Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Simple Compiling Question" Watch "Simple Compiling Question" New topic
Author

Simple Compiling Question

Daniel Foreacre
Greenhorn

Joined: Feb 21, 2003
Posts: 4
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

Joined: Feb 18, 2003
Posts: 8
you say this command :
c:\path of jdk\bin\> javac yourprogram.java
Daniel Foreacre
Greenhorn

Joined: Feb 21, 2003
Posts: 4
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

Joined: Feb 18, 2003
Posts: 8
Is your program run "main" ?
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
make sure that your program has a properly formatted main method:
public static void main(String[] args) {
}


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
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?


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
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.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Daniel Foreacre
Greenhorn

Joined: Feb 21, 2003
Posts: 4
Thanks for the link to Sun. Turns out the path for javac wasn't set right. It's compiling now
Dan
Daniel Foreacre
Greenhorn

Joined: Feb 21, 2003
Posts: 4
That error message was generated when I tried executing Test, but since it wasn't compiled it wouldn't do anything (I think).
Dan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple Compiling Question
 
Similar Threads
Environment Variables
NX: URLyBird 1.1.3 Find criteria
Java command options
Dev-C++ or Microsoft Visual C++ 2008
Dan't figure out how to compile.