aspose file tools*
The moose likes Beginning Java and the fly likes confusion over class imports Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "confusion over class imports" Watch "confusion over class imports" New topic
Author

confusion over class imports

Chris Davies
Ranch Hand

Joined: Feb 26, 2003
Posts: 110
hi

i'm trying to compile a class. and am getting the following error message



both of these jar files are imported at the top of my class. they are alos pointed to in the environment variable classpath.

when i run the following command

javac -classpath "C:\beans\" webtopjdbc2.java

i get no message to the prompt but it wont compile.

cheers

chris


One day all greenhorns will run free ...
Greg T Robertson
Ranch Hand

Joined: Nov 18, 2003
Posts: 91
I do believe that if you are specifying them in your environment varaible in your classpath then you are overwriting them for javac when you specify -classpath for it. You should try (assuming MS based OS) javac -classpath %classpath%;c:\beans compileme.java
Chris Davies
Ranch Hand

Joined: Feb 26, 2003
Posts: 110
thanks is it all of this ?

i've tried

javac -classpath %classpath%;c:\beans webtopjdbc2.java

and it give too many arguments

and

javac %classpath%;c:\beans webtopjdbc2.java

which also gives the error



??
Greg T Robertson
Ranch Hand

Joined: Nov 18, 2003
Posts: 91
The error regarding "C:\Progra " occurs on some versions of windows (sorry not sure exactly which ones) when you have a reference to a directory or file in your classpath that contains a space in it. The solution i've always used is to use the DOS name for the path (e.g. c:\progra~1)
Chris Davies
Ranch Hand

Joined: Feb 26, 2003
Posts: 110
thanks

i work between unix and windows - could you elaborate a bit ? do you mean the reference to the directory where the jar files are ? what is the dos pathname ?there is a space in the tomcat directory file - C:\Tomcat 4.1. but this isn't leading to one of the classpaths.

should i rename all files in the classpaths with a space in them ?

cheers

chris
Greg T Robertson
Ranch Hand

Joined: Nov 18, 2003
Posts: 91
On windows when you have a space in a directory name (like \Program Files) in some instances it will wreak havoc on things like classpath. So if you do (at a command prompt) an "echo %classpath%" (sans quotes) - i'm betting that somewhere in your classpath you have something referencing a jar (or path) like C:\Program Files\SomeDir\Some.jar . My suggestion was to set your classpath so that it uses the dos short name for the files to remove spaces which would be: C:\Progra~1\SomeDir\Some.jar - your further question it seems is how to determine the DOS short name. I believe it works like this - if a filename (or directory) would be longer than 8 characters before the "." (filenmae extension) to figure out the short name use the first 6 characters and then add a ~1 to it (in 90% of cases this works to figure out the name). The other 10% we hopefully don't need to delve into here. If you do the echo and still have issues, post the value of the echo here and I'll see if I can help you along anymore.
Chris Davies
Ranch Hand

Joined: Feb 26, 2003
Posts: 110
thanks

when i use the "echo %classpath%" in the directory of my files (it shouldn't it returns the following

C:\Program Files\Altova\xmlspy\XMLSpyInterface.jar

however when i got control panel/system/advanced/environment variables

and go to edit the CLASSPATH i have the following

C:\Tomcat 4.1\common\lib\servlet.jar;C:\beans\basiswebtop.jar;C:\beans\basisjdbc.jar;

i can't figure out where its picking up the xmlspyinterface.jar from ???

i installed a dveloper version of beaweblogic which contains a free evaluation of xmlspy but how come this is the classpath ? is it set in the registry or something ?

any ideas as to why this doesn't show up in the environment folder ??

cheers

chris
Greg T Robertson
Ranch Hand

Joined: Nov 18, 2003
Posts: 91
Well you don't specify which OS you are on, but if it's a 2k or XP system check both user classpath and system classpath. Perhaps XMLSpy set itself in the user as opposed to system classpath. Worst case you can set the classpath at the command line by hand or pass it to javac using the -classpath arg. But definitely check both the user & system settings.
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
Yeah, XMLSpy automatically adds its jar(s) into the user classpath. That annoyed me so I just removed it. You don't even need the jar in your classpath unless you are planning on actually interfacing with XMLSpy through some Java code.


Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
Chris Davies
Ranch Hand

Joined: Feb 26, 2003
Posts: 110
i see it.

i've a company user classpath setup within the environment variables page and all this time i've been looking at the system variable, which was clearly being overridden by the company user classpath

cheers
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: confusion over class imports
 
Similar Threads
non compiling drop down list
compiled or not compiled
import java.*; ????
jdbc questions
Compiling JSF java bean - "javax.faces.context does not exist"