I'm trying to finish an assignment for Uni and am running into problems because my compiler can't seem to see a couple of classes required by my code.
To elaborate, our lecturers have provided 2 classes to help with input and output of Strings/ints and providing a date and time. With the help of these classes, I'm supposed to code a kind of quiz game.
I'm ok with the coding, but whenever I try and include methods from the 2 pre-defined classes - the compiler doesn't seem to see them, even though they're in the same folder as my code. What am I doing wrong?
Are you certain that you're specifying the class names exactly as they appear? (These are case-sensitive.)
I thought that javac always looked in the same directory for other classes (packages aside), but maybe I'm wrong. You could try adding a period to your classpath options to indicate the current directory. See the following page*... http://faq.javaranch.com/view?HowToSetTheClasspath
* Note: In the unlikely event you are running Windows ME, then editing autoexec.bat will not work to set classpath. Instead, select Start / Programs / Accessories / System Tools / System Information. A "Microsoft Help and Support" window should appear. From the Tools menu in this window, select System Configuration Utility, then click on the Environment tab to set classpath.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Joined: Mar 04, 2004
I'm definitely typing the class names ok.
I've tried sorting this issue in the netBeans IDE and using notepad and the command window and swapping around files/directories etc; nothing seems to work. I'm relatively new to Java and have no idea how to set classpaths and such - the link didn't do much to enlighten me I'm afraid, although I did do what it said and still no change.... I feel like I'm banging my head against a wall!
Are there package declarations at the beginning of these java files? For example, if the text starts with...
...then you'll need to save that file in a directory called "somePackageName" and set the classpath accordingly. Then if another java file outside of that package needs to use it, you'll need an import statement like...
Joined: Mar 04, 2004
Ok. Thanks. Will give that a try.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com