Hi,
I am a new JAVA student trying to compile a very simple program using software from the Java 2 SDK CD from the Dietel book. I installed the software on my PC, along with a trial version of TextPad (to use as a text editor). If it matters, I have Windows XP installed on my PC.
Here's the source code:
import javax.swing.*;
public class program1
{
public static void main (String s[])
{
// body of main method
JOptionPane.showMessageDialog(null, "Hello!");
System.exit(0);
}
}
----------------------------------------
Here's the response in TextPad, after I attempt to "Compile Java":
javac: invalid argument: C:\CIS217\program1.JAVA
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-O Optimize; may hinder debugging or enlarge class file
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-target <release> Generate class files for specific VM version
Tool completed with exit code 2
-----------------------------------------------------
It's as if the Java compiler isn't even recognizing my file. I have updated the autoexec.bat file to include the path for the Java executable file. Anyone know what I'm doing wrong???
Any help would be greatly appreciated! Thanks!
XP - java not compiling
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Re: XP - java not compiling
Not sure what I did differently on my system, but now when I try to compile Java from TextPad with a file that's in my working directory, the dialog box says "C:\WINDOWS\System32\javac.exe" with a warning message that "The system cannot find the file specified."
First, that is not the directory where the java executable is located (it is under C:\jdk131\bin). Also, the file is loaded into TextPad prior to compiling.
Any clues out there?
By the way, I am not able to affect the PATH to include the directory where the java executable is stored. Anyone see this before? Tried changing it in Control Panel under System->Advanced->Environment Settings. But, no change.
Thanks again,
Laura
First, that is not the directory where the java executable is located (it is under C:\jdk131\bin). Also, the file is loaded into TextPad prior to compiling.
Any clues out there?
By the way, I am not able to affect the PATH to include the directory where the java executable is stored. Anyone see this before? Tried changing it in Control Panel under System->Advanced->Environment Settings. But, no change.
Thanks again,
Laura
Re: XP - java not compiling
Hi, Laura
I just read your post today, and I was wondering if you ever solved your Java compiling problem?
If you haven't, let me know, because there is a way to compile Java programs with Textpad when the computer PATH/CLASSPATH variables don't seem to be working out.
If you would like, I'd be happy to send you an explanation and directions.
Cheers,
Peter
I just read your post today, and I was wondering if you ever solved your Java compiling problem?
If you haven't, let me know, because there is a way to compile Java programs with Textpad when the computer PATH/CLASSPATH variables don't seem to be working out.
If you would like, I'd be happy to send you an explanation and directions.
Cheers,
Peter
Re: XP - java not compiling
I am getting that same error about \"C:\WINDOWS\System32\javac.exe\" can not find th file, so i did a search for it and still couldnt find it.
Re: XP - java not compiling
In the same situation (new Java student) and having the same problem as Laura. Any suggestions?
Re: XP - java not compiling
I was having the problem with javac.exe not being found. I was able to solve that issue with the following download:
http://java.sun.com/products/jdk/1.1/do ... ndows.html
Hope it works for you.
But now I am unable to run programs that contain the line:
javax.swing.*;
I've inserted the code to import javax.swing. I am guessing that swing object is part of a jar, which I've not uncompressed or have not been able to find. Any information would be most appreciated.
http://java.sun.com/products/jdk/1.1/do ... ndows.html
Hope it works for you.
But now I am unable to run programs that contain the line:
javax.swing.*;
I've inserted the code to import javax.swing. I am guessing that swing object is part of a jar, which I've not uncompressed or have not been able to find. Any information would be most appreciated.
Re: XP - java not compiling
I had the same problem with the javac.exe error. It seems that you do have to dl the JDK software development kit. Im dl it right now and ill tell you if it helps me or not. Thanks Ray.
Re: XP - java not compiling
this is the error message i get when trying to compile a simple example program for my java class.
javac: invalid flag: C:\Documents and Settings\maXXimus\My Documents\java_progs\Chap2_DisplayMessage.txt
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-O Optimize; may hinder debugging or enlarge class file
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-help Print a synopsis of standard options
Tool completed with exit code 2
i added the javac program to my list of tools in preferences. and i'd rather not mess with my environment variables unless the information i recive is positive about the steps that need to be taken to resolve the problem.
HOPE SOMEONE CAN HELP ME OUT!
javac: invalid flag: C:\Documents and Settings\maXXimus\My Documents\java_progs\Chap2_DisplayMessage.txt
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-O Optimize; may hinder debugging or enlarge class file
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-help Print a synopsis of standard options
Tool completed with exit code 2
i added the javac program to my list of tools in preferences. and i'd rather not mess with my environment variables unless the information i recive is positive about the steps that need to be taken to resolve the problem.
HOPE SOMEONE CAN HELP ME OUT!