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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problems installing java" Watch "problems installing java" New topic
Author

problems installing java

Kim raddon
Greenhorn

Joined: Apr 25, 2004
Posts: 5
My error msg. follows. I downloaded java, that cut and pasted the helloworld.java test program into notepad, saved it to helloworld.java in the java dir. and attempted to compile it.
I am running windows 98. any help would be much appreciated.
Thanks, Kim

C:\Program Files\Java>javac helloworld.java
Bad command or file name
Krishnan Loganathan
Greenhorn

Joined: Apr 24, 2004
Posts: 23
Kim raddon
greenhorn
Member # 71791
posted April 25, 2004 12:40 AM
--------------------------------------------------------------------------------
My error msg. follows. I downloaded java, that cut and pasted the helloworld.java test program into notepad, saved it to helloworld.java in the java dir. and attempted to compile it.
I am running windows 98. any help would be much appreciated.
Thanks, Kim

C:\Program Files\Java>javac helloworld.java
Bad command or file name
Hai Kim,
set the path of the java installed dir to the current directory, then try it. otherwise use the classpath option in the javac command, so that it will point to the source file directory as follows. Meanwhile check the filename also.
c:\Program Files\java> javac -classpath .; helloworld.java
I think so, it will help for you.
Cheers
Loga
Kim raddon
Greenhorn

Joined: Apr 25, 2004
Posts: 5
Thanks, that helped a little, I set the path to: ;j2sdk1.4.2_04\bin
I copied helloworld.java into \bin
this is the result:
C:\j2sdk1.4.2_04\bin>javac -g helloworld
javac: invalid flag: helloworld
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
........ followed by a list of possible options, of which I used -g
All advice is welcomed
Kim
Leo Khan
Greenhorn

Joined: Apr 20, 2004
Posts: 2
javac -g HelloWorld.java for compiling
java HelloWorld for execute the byte code
Kim raddon
Greenhorn

Joined: Apr 25, 2004
Posts: 5
I have included the console log below.
I am running j2sdk1.4.2_04, and the book I am using is for jdk 1.3
Is there some syntax differences between the two versions?
What cmd is java expecting to see?
Thanks in Advance,
Kim
>>>>>>>>>>>>>>
C:\j2sdk1.4.2_04\bin>javac HelloWorldApp.java
C:\j2sdk1.4.2_04\bin>java HelloWorldApp
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp
C:\j2sdk1.4.2_04\bin>
>>>>>>>>>>>>>>>>
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, Kim!
I'd encourage you to not use the J2SDK/bin folder for storing your source code - that's just messy. A better organization might be something along the lines of C:\java\projects\project1
For your PATH setting, you'll want to include C:\j2sdk1.4.2_04\bin not ;j2sdk1.4.2_04\bin
Then, you should be able to execute the javac command from any working directory.
If your source code file is named helloworld.java, then the command to compile it would be javac helloworld.java
[ April 25, 2004: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Your commands look correct, except for the part where you're storing your source code in the J2SDK/bin folder.
Your problem with running the compiled program is either a CLASSPATH setting issue, or it's to do with the actual source code that's inside the HelloWorldApp.java file.
Note that the CLASSPATH setting should likely include the current working directory, which your's may not. What happens if you try to run the program with the following command?
java -cp . HelloWorldApp
For tips and steps on setting the CLASSPATH, take a look at our wiki on the subject.
If that doesn't solve the problem, then what is defined in the HelloWorldApp.java source file? Does it define a HelloWorldApp class? Is a file named HelloWorldApp.class created after compiling HelloWorldApp.java?
[ April 25, 2004: Message edited by: Dirk Schreckmann ]
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
also remember you need to boot your machine for changes to the path to take effect when using Windows 98.


42
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Jeroen: No. You needn't.
You may modify the settings for the command.com, and just open a new command-window.
Test it with

Kim:
'Bad command or filename' definetivly means, javac isn't found.
Due to Coding-standards, your File should be named 'HelloWorldApp.java' and not 'helloWorldApp.java'. But then your classname needs to be 'HelloWorldApp' too.
I'm nearly exclusively using Linux, but I used Dos/ Windows for a (too) long time.
And I don't need any -cp or -classpath for starting a class in the current folder. Of course Linux is much better than Windows - but I don't think in this issue.
And I don't have any CLASSPATH - variable set.
Try to get into the folder, where the HelloWorldApp.java is, when compiling, and where the HelloWorldApp.class is, when running.

I'd like Krishnan and Dirk to test their suggestion if possible (and mine too).
The classpath is needed if you refer to other packages, or if your classes are in a different dir - but a '.' will not work then either.
Perhaps this changed someonce in the past?
(editing note that notepad uses to append a '.txt' to any file, making your HelloWorldApp.java to HelloWorldApp.java.txt
I would at least recommend to use 'scite' as a lean and free editor, which knows syntax-highlightening and handles multiple files.
[ April 26, 2004: Message edited by: Stefan Wagner ]

http://home.arcor.de/hirnstrom/bewerbung
Kim raddon
Greenhorn

Joined: Apr 25, 2004
Posts: 5
I'm sorry to keep troubling you with a problem that is most likely very remedial, but I can't begin studying Java until I resolve this.
Here is all of the info I think might be relevant:
all advice is again welcome.
Kim

SET CLASSPATH=.;%CLASSPATH%;C:\java
<<<<console log>>>>>>>>>
C:\java>javac HelloWorld.java
C:\java>java HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
C:\java>

>> source code <<
public class HelloWorld
{
public static void main( String[] args )
{
System.out.println("hello world!");
}
}
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Kim,
What's output when you run the following command, from the exact same console window where running the Java program is failing?
ECHO %CLASSPATH%
Also, just to be certain and clear, after compiling, is a file name HelloWorld.class created in the C:\java directory?
What happens when running the following command?
java -cp . HelloWorld
[ April 29, 2004: Message edited by: Dirk Schreckmann ]
Kim raddon
Greenhorn

Joined: Apr 25, 2004
Posts: 5
Ok, I just retyped the classpath in, and rebooted, and the program compiled and ran correctly.
Thanks all for you help. I'm really excited to actually start the java tutorial.
Thanks again, Kim
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Great!
As you're learning, you might like to have on hand the following list of free on-line Java tutorials and books that I have found useful:
  • Sun's Java Tutorial
  • Introduction to Computer Science using Java by Bradley Kjell
  • Introduction to Programming Using Java by David J. Eck
  • Dick Baldwin's Java Programming Tutorials
  • Interactive Programming In Java by Lynn Andrea Stein
  • Bruce Eckel's Thinking In Java
  • JavaRanch's own Campfire Stories
  • Allen B. Downey's How To Think Like A Computer Scientist

  • Good luck and I hope to see you 'round the Ranch!
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: problems installing java