Fred Freeley

Greenhorn
+ Follow
since Sep 24, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Fred Freeley

I guess I missed that obvious fact.

Thanks for your patience,

David
14 years ago
Hi,

When I appended a "." to the classpath, I get the following results:

D:\sandbox\project1\src->echo %CLASSPATH%
d:\jdk-1_5_0_09\lib;D:\Apache\Tomcat_5_5\common\lib;.

D:\sandbox\project1\src->type HelloWorld.java

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

}
D:\sandbox\project1\src->java HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld

D:\sandbox\project1\src->java HelloWorld.java
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/java

D:\sandbox\project1\src->javac HelloWorld.java

D:\sandbox\project1\src->java HelloWorld
Hello World

As you can see, if I compile it first, then run it from the *.class, it works. I then tried to force the classpath as you suggested:

D:\sandbox\project1\src->del *.class

D:\sandbox\project1\src->java -cp . HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld

D:\sandbox\project1\src->java -cp . HelloWorld.java
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/java

D:\sandbox\project1\src->java -classpath . HelloWorld.java
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/java

D:\sandbox\project1\src->java -classpath . HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld

D:\sandbox\project1\src->

I am lead to believe that if a classpath is not specifically defined, the current directory is tried first. I have tried specifying a classpath, forcing a classpath locally and clearing the classpath and forcing the classpath on the command line, with the same result: it will work only if I compile it firat, then execute it from the class. I cannot get it to compile and execute directly such as "java HelloWorld"

I guess it is not a big deal, I can build a batch file that will do that for me, I would just like the command line invocation to work like the book advertizes.
14 years ago
C:\Documents and Settings\David\Desktop>echo %CLASSPATH%
d:\jdk-1_5_0_09\lib;D:\Apache\Tomcat_5_5\common\lib
14 years ago
Hey all, I feel very stupid, but I can't seem to get "Hello World" dummy program to work. Any help would be appreciated!

I am trying to use the "Head First Java" book to get up to speed with java, but am running into a fundamental problem that is driving me crazy!

Just the facts 'mam:
Running XP, Service Pack 2 (fixes long environmental variable parameter problems)

I downloaded "JDK 5.0 Update 6 with Java EE" from java.sun.com,
the download completed and installed. I decided it was not what I wanted so I uninstalled it using the uninstaller provided.

I then installed the newest JDK: "JDK 5.0 Update 9"
"jdk-1_5_0_09-windows-i586-p-iftw.exe" and it seemed to install without hassles.

Java JDK lives here: d:\jdk-1_5_0_09
Environment variable JAVA_HOME is: d:\jdk-1_5_0_09
Environment variable CLASSPATH is: d:\jdk-1_5_0_09\lib
Environment variable PATH is: PATH=C:\bat;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI.ACE\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\OrCAD\OrCAD_10.0\tools\pcb\bin;C:\OrCAD\OrCAD_10.0\tools\specctra\bin;C:\OrCAD\OrCAD_10.0\tools\PSpice\Library;C:\OrCAD\OrCAD_10.0\too
ls\bin;C:\OrCAD\OrCAD_10.0\tools\fet\bin;C:\OrCAD\OrCAD_10.0\tools\jre\bin;C:\OrCAD\OrCAD_10.0\tools\Capture;d:\jdk-1_5_0_09\bin

When I query javac ("javac -version") I get:
D:\sandbox\project1\src->javac -version
javac 1.5.0_09
javac: no source files ....

When I query java ("java -version") I get:
D:\sandbox\project1\src->java -version
java version "1.5.0_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode, sharing


When I execute javac, it compiles without errors:
"javac HelloWorld.java"

and produces a HelloWorld.class file.


Code: (saved as HelloWorld.java)

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

}

If I try to run it directly I get the following error:
D:\sandbox\project1\src->java HelloWorld.java
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/java

If I try to execute the HelloWorld class I get a similar error:
D:\sandbox\project1\src->javac HelloWorld.java

D:\sandbox\project1\src->java HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld

This has to be simple operator error. Any ideas?

Thanks
14 years ago
I have a DVM that spits out readings on a serial port. How do I "connect" that serial stream to something I can read using Java?
15 years ago