Don Sartain

Greenhorn
+ Follow
since Dec 24, 2006
Merit badge: grant badges
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 Don Sartain

Ok, I finally got everything working. I had to modify the Linux Classpath by

CLASSPATH=path
export CLASSPATH



Then I had to go to my source directory and compile using


javac -classpath $CLASSPATH path/to/filename.java



Then I went to my classes directory and ran the file with


java net.the24hourshow.GuessGame.GameLauncher



The source code is already posted, but I did have to make sure I included the package statement in each class, without trying to import the classes that were in the same package.



Thanks to those that helped.
17 years ago
Ok, good news is that I got all of these classes to compile by typing


javac -d ../classes -classpath ../classes/net/the24hourshow/GuessGame net/the24hourshow/GuessGame/*.java



I was able to compile them individually as well...

Problem is when I run "[dsartain@localhost classes]$ java -classpath "." net.the24hourshow.GuessGame.GameLauncher.class" it gives me the error below...Any ideas...the code hasn't changed, other than me removing the import lines....Also, I can run this fine in the NetBeans IDE, but as I will most likely not be using that the majority of the time, I'd like to get this command line thing working...


[dsartain@localhost GuessGame]$ java -classpath "." net.the24hourshow.GuessGame.GameLauncher.class
Exception in thread "main" java.lang.NoClassDefFoundError: net.the24hourshow.GuessGame.GameLauncher.class
at gnu.java.lang.MainThread.run(libgcj.so.7rh)
Caused by: java.lang.ClassNotFoundException: net.the24hourshow.GuessGame.GameLauncher.class not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.7rh)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.7rh)
at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
at gnu.java.lang.MainThread.run(libgcj.so.7rh)


[ January 31, 2007: Message edited by: Don Sartain ]
17 years ago
Yes, all the classes are part of the same package, but it still wouldn't work...I renamed the package to be more normal, so now it's just just net.the24hourshow with .GuessGame as the subpackage...I'll repaste my code again, maybe it's something else....Also, because I have the subpackage named GuessGame, I renamed the class GuessGame2...

I'm sorry it's taking me so long to get this, I just don't see what the problem is...all the classes are in the same folder, declared in the same package, so I shouldn't have to import anything, but I get the same errors either way....



Code above receives this error:
----------
1. ERROR in net/the24hourshow/GuessGame/GameLauncher.java (at line 2)
import GuessGame.*; //imports subpackage
^^^^^^^^^
The import GuessGame cannot be resolved
----------
2. ERROR in net/the24hourshow/GuessGame/GameLauncher.java (at line 3)
import GuessGame.GuessGame2; //imports subpackage.class
^^^^^^^^^
The import GuessGame cannot be resolved








1. ERROR in net/the24hourshow/GuessGame/GuessGame2.java (at line 3)
import GuessGame.*; //imports subpackage
^^^^^^^^^
The import GuessGame cannot be resolved
----------
2. ERROR in net/the24hourshow/GuessGame/GuessGame2.java (at line 4)
import GuessGame.Player; //imports subpackage.class
^^^^^^^^^
The import GuessGame cannot be resolved
----------

17 years ago
while I haven't looked at your code in detail, why not just do an if statement somewhere that is like:



Note: I'm new to java, so the syntax may be wrong, but I've had to do similar things in C++ and something like that worked...a bit crude, but it worked...
[ January 30, 2007: Message edited by: Don Sartain ]
17 years ago
Files are in /home/dsartain/Desktop/java/source/net/the24hourshow/GuessGame

package = net.the24hourshow.GuessGame
classpath = /home/dsartain/Desktop/java/classes

Modified Files:


is at the beginning of GuessGame.java...

when I run javac -classpath /home/dsartain/Desktop/java/classes -d ../classes net/the24hourshow/GuessGame/GuessGame.java

I had to add the -classpath parameter to get the import to work...for some reason it still wants me to do that, even though I packaged the classes..

I get the following error:

1. ERROR in net/the24hourshow/GuessGame/GuessGame.java (at line 4)
import Player.*;
^^^^^^
The import Player cannot be resolved
----------



Any ideas where I'm messing up...this whole Head First book isn't making any sense when it comes to this...
17 years ago
well, the directory that the java files are in is /home/dsartain/Desktop/java/code_projects/GuessGame

Yes, I'm using Linux for this...

All files are in the same folder, so would I need to import that entire line, or is there a way to edit the java.conf file to include the bulk of that in a classpath or something??
17 years ago
They aren't a part of a package...I tried importing them, but that didn't work...they're all in the same directory, so I should just be able to

right???

If not, how do I do that?? I can import the standard java.* fine, but it's the custom classes I'm having issues with....
17 years ago
I'm working on an exercise out of a book, it seems fairly straight forward, but I'm getting a couple of errors that I can't figure out...I'm pasting the file then the error afterwards...I think my problem is that I don't know how to reference classes that are in a separate file, but I'm not sure....any help would be greatly appreciated...


The Player class compiles fine...

----------
1. ERROR in GameLauncher.java (at line 9)
GuessGame game = new GuessGame();
^^^^^^^^^
GuessGame cannot be resolved to a type
----------
2. ERROR in GameLauncher.java (at line 9)
GuessGame game = new GuessGame();
^^^^^^^^^
GuessGame cannot be resolved to a type
----------
2 problems (2 errors)




1. ERROR in GuessGame.java (at line 5)
Player p1;
^^^^^^
Player cannot be resolved to a type
----------
2. ERROR in GuessGame.java (at line 6)
Player p2;
^^^^^^
Player cannot be resolved to a type
----------
3. ERROR in GuessGame.java (at line 7)
Player p3;
^^^^^^
Player cannot be resolved to a type
----------



obviously, this last bit had more than three errors, but once I get those fixed, the rest will go away...
17 years ago
Well, I can still create/run Java programs with what I've got...I mainly wanted to download the tools bundle because it comes with the API docs...or so I thought...but it's working now, and if I really need to figure something out I can always do it on my pc...so thanks to those who posted.
17 years ago
Yes, I meant to install the EE package. This package includes a JRE.

The JRE path is /opt/SDK/jdk/jre/bin

I adjusted the PATH to include /opt/SDK/jdk/bin and /opt/SDK/jdk/jre/bin, but I couldn't find the $JAVA_HOME reference.

I tried "echo $JAVA_HOME" but got a blank line as a result.

How can I create that??

/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/opt/SDK/jdk/bin:/opt/SDK/jdk/jre/bin



is my full path, and even though FC6 did install some other version of JAVA, I don't think it's actually running or in the path.
17 years ago
Ok, I installed java_ee_sdk-5_02-linux.bin from the java.sun.com download page. I know where it installed to...bin path = /opt/SDK/jdk/bin...

The problem comes when I try to install java-tools-bundle-linux.sh...I need to know how to specify where the JRE is located...It gives me the following error message...


No compatible Java SE Runtime Environment (JRE) was found on this system.
The NetBeans(TM) 5.5 Preview installer requires at least JRE
version 5.0. Download and install a compatible JRE and try again or
restart the installer using the -is:javahome command line parameter to
specify the location of the JRE.



I've tried several ways of doing this, all to no avail. Can someone point me in the right direction?? Do I even have the right path (where the java and javac files are located)??

Thanks.
17 years ago