Thoughts Media.com

 




  #1 (permalink)  
Old 09-07-2003, 02:57 AM
Intellectual
Join Date: Jul 2003
Posts: 218
Default Java Question

Sorry, this is perhaps not the best place to ask this question since it is not Pocket PC related, but this is the only place I could think of after searching for about 30 minutes on the net plus you developers could help me (who knows, maybe I'll write something for PPC in a few decades...).
Here's the deal, I just started learning Java after working with C++ for a little while. I have downloaded and installed the newest SDK (1.4.2 I think) from java.sun.com.

Now I need to edit and compile my code through Command Prompt. So I set up the DOS Box to work with the Java Compiler and made a dir to work in and also made some modifications to the sysedit file based on some advice I got from a beginner java site.

The compiler works well, but I have problems importing files:

I have put the following three files I needed for some specific project in the same directory as my other java files (C:\JavaFiles):

TerminalIO.jar
TurtleGraphics.jar
BreezySwing.jar

But when I try to import them (TerminalIO for example) in my program and compile them I get the following error message:
******************
test.java:1: package TerminalIO does not exist
import TerminalIO.*;
^
1 error
******************
Now I thought as long as I have those *.jar files in the dir, i should be OK; but it doesn't seem so. Do i need the files to be in some mysterious "package format"? Do I need to make a batch file? Any help would be greatly appreciated.
 
Reply With Quote
  #2 (permalink)  
Old 09-07-2003, 03:03 AM
Pontificator
Join Date: Aug 2006
Posts: 1,183

This sounds like a problem with how the classpath is set.

How are you setting the classpath in the compile command line?
 
Reply With Quote
  #3 (permalink)  
Old 09-07-2003, 03:12 AM
Moderator
Steven Cedrone's Avatar
Join Date: Aug 2006
Posts: 5,999
Default Re: Java Question

Quote:
Originally Posted by mirkazemisaman
Sorry, this is perhaps not the best place to ask this question since it is not Pocket PC related
Never hurts to ask... :wink:

I did move the post to the "Off-Topic" forum though...

Steven Cedrone
Community Moderator
__________________
"My eyes are rolling back in my head so far I can see my grey matter bubbling and frothing from reading this thread....bleh." JD
 
Reply With Quote
  #4 (permalink)  
Old 09-07-2003, 04:15 AM
Contributing Editor
Janak Parekh's Avatar
Join Date: Aug 2006
Posts: 14,942

Jacob hit the nail precisely on the head. Java relies on an environment variable called the CLASSPATH. If you don't have it set, by default it's set to ".", i.e., the current directory. However, it will only look for .class files in that directory. In order for it to look inside JAR files, you must explicitly specify them in the CLASSPATH, or use a special parameter to java/javac. If you do, make sure to add a "." or the path to the directory itself so that the .class files will still be found.

See this Java documentation page for the full details on how this stuff works.

BTW, if you don't want to deal with these hassles, download an IDE; they automate much of the process. NetBeans and Eclipse are two fantastic completely free IDEs.

--janak
 
Reply With Quote
  #5 (permalink)  
Old 09-07-2003, 05:51 AM
Intellectual
Join Date: Jul 2003
Posts: 218

ummm. i don't know 8O . I did set the class path. Although I really shouldn't have to since the files are in the same directory. Anyways it still doesn't work.
I am probobly going to go with an IDE...
 
Reply With Quote
  #6 (permalink)  
Old 09-07-2003, 05:53 AM
Contributing Editor
Janak Parekh's Avatar
Join Date: Aug 2006
Posts: 14,942

Quote:
Originally Posted by mirkazemisaman
ummm. i don't know 8O . I did set the class path. Although I really shouldn't have to since the files are in the same directory.
No. You must set the CLASSPATH. And you must explicitly state the JARs in them. e.g., something like

Code:
set CLASSPATH=C:\JavaFiles;C:\JavaFiles\TerminalIO.jar;C:\JavaFiles\TurtleGraphics.jar;C:\JavaFiles\BreezySwing.jar
would be the best.

Trust me, I've been programming Java for 7 some-odd years and even teach it.

--janak
 
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 11:54 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC7
Copyright Thoughts Media Inc. 2007