Javac classpath problem
I get this error when trying to compile a simple program:
# javac -classpath .;/mnt/bdrive/MyData.class Test.java
javac: no source files
Usage: javac <options> <source files>
where possible options include:
***snip***
bash: /mnt/bdrive/MyData.class: Permission denied
It seems to be a problem with specifying more than one thing for the classpath. If I remove the ".;", it works. (I don't need the . in the classpath but I should be able to specify it)
probably :)
I originally had just the path and was trying it different ways. If I use just the path instead of the permission denied message, I get this:
bash: /mnt/bdrive/: is a directory
Similar Messages
-
i am here stuck..
my dir structure is
c:\my\xxx\yyy\zzz
i have a code ...
package xxx.yyy.zzz;
class A
// some code
}i have compiled sucessfully and put the clsss file into c:\my\xxx\yyy\zzz folder.
now i want to import it in another class
like...
package xxx.yyy; // note this
import xxx.yyy.zzz.*; // note this
class B
// some code
// creating instance of class A here
}question is how do i compile and run it ?
i am at c:\my---> what should be the command to compile and run the above code?
plz give me the explicit command so that i can test and verify . i have given the dir structure.
i have tried several ways but got class not found exception and errors . i know its a classpath problem but i could not figure out what should i type at the c:\my prompt.
can u give exact command to run and compile the above code in steps ?
thanxquestion is how do i compile and run it ?You don't with that code. You've defined class A to have "package visibility," meaning it can't be used from outside its package. You should declare it with public visibility instead, like "public class A {...".
Once you change that, use these commands to compile and run:c:\my\>javac xxx/yyy/zzz/A.java
c:\my\>javac xxx/yyy/B.java
c:\my\>java xxx.yyy.B -
Hi all,
I'm trying to develop a simple application using JMF; I've problems importing classes from javax.media package. Problem with my application is that when I explicitly specify classpath as a command line argument to javac my application compiles; but if I use CLASSPATH environment variable it doesn't. Here's the output:
situ@situ-desktop:~/myjava/media$ cat First.java
import javax.media.*;
public class First{
situ@situ-desktop:~/myjava/media$ echo $CLASSPATH
/home/situ/jmf/JMF-2.1.1e/lib/jmf.jar:/home/situ/jmf/JMF-2.1.1e/lib/sound.jar:.:
situ@situ-desktop:~/myjava/media$ javac First.java
First.java:1: package javax.media does not exist
import javax.media.*;
^
1 error
situ@situ-desktop:~/myjava/media$ javac -classpath /home/situ/jmf/JMF-2.1.1e/lib/jmf.jar First.java
situ@situ-desktop:~/myjava/media$
Thanks.According to the documentation, it wants you to set two environmental variables, JMFHOME and CLASSPATH. And it wants the CLASSPATH to be relative to that JMFHOME variable.
Try this.
setenv JMFHOME /home/someuser/JMF2.1.1
setenv CLASSPATH $JMFHOME/lib/jmf.jar:.:${CLASSPATH} -
again classpath problem.... i have tried to solve it in many ways but all failed. here is one
instance of my effort which did not give me success.
i have a FOLDER > c:/com/abc/def/ijk
and files......
MyClass.java
==============
package com.abc.def.ijk
class MyClass
// blah
// blah
}c:\com\abc\def\ijk>javac MyClass.java ===>compiled fine and created a class file.
and also one more file.....
OneMoreClass.java
=================
import com.abc.def.ijk.MyClass
class OneMoreClass
// blah
// blah
}c:\com\abc\def\ijk>javac OneMoreClass.java ===> Error!!! package com.abc.def.ijk does not exist !!!!
how can i solve it ?yea, this works....eariler i also usued to do this
way. but this time i forgot.
by the way, why individually it did not work !!!.Because you were in the package directory itself, and the classpath was set to the cwd, so java was looking for package directories at this level.
and also when i specify directly by
c:\com\abc\def\ijk
javac -classpath c:\com\abc\def\ijk\MyClass
OneMoreClass.java ...it does not work!!.
STRANGE! why ?Because by stating the package directory as classpath, you do the same as explained above. Stay out of package directories, stay one level above them, don't regard them as common directories. When declaring classpaths, don't mention package directories but the directories that contain them. -
Help classpath problem j2sdk1.4.2_04
help classpath problem j2sdk1.4.2_04
how can i run the java program with specify the file location
such as :
-----this one is fine ok and return HelloWorld.class-----
[root@localhost root]javac /serverData/studentAC/s001/HelloWorld.java
-----but this one cause exception-----
[root@localhost root]java /serverData/studentAC/s001/HelloWorld
-----result-----
Exception in thred "main" java.lang.NoClassDefFoundError: /serverData/studentAC/s001/HelloWorld
[root@localhost root]
I have tried a lot of classpath setting:
I just want to compile and run the java program without specify the classpath only !! please help !!! and give suggest !! if you have this exp!!
# ---1
#PATH=/usr/java/j2sdk1.4.2_04/bin:$PATH:$HOME/bin:./
#export PATH
#export JAVA_HOME=/usr/java/j2sdk1.4.2_04/
#export #CLASSPATH=/usr/java/j2sdk1.4.2_04/lib/tools.jar:/usr/java/j2sdk1.4.2_04/jre/lib/rt.jar:./
# ---2
#set java environment
# Java Setup Section START
export JAVA_HOME="/usr/java/j2sdk1.4.2_04"
export JRE="$JAVA_HOME/jre"
export CLASSPATH="$JAVA_HOME/lib:$JRE/lib:$JAVA_HOME/lib/tools.jar:."
export PATH="$PATH:$JAVA_HOME/bin"
# Java Setup Section END
# ---3
#PATH=$PATH:/usr/java/j2sdk1.4.2_04/bin
#JAVA_HOME=/usr/java/j2sdk1.4.2_04/
#export PATH
# ---4
# Java Setup Section START
#JAVA_HOME=/usr/java/j2sdk1.4.2_04
#export JAVA_HOME
#CLASSPATH=$CLASSPATH:/usr/java/j2sdk1.4.2_04/lib:/usr/java/j2sdk1.4.2_04/jre/lib:./
#export CLASSPATH
#PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
#export PATH
# Java Setup Section END
# ---5
#export PATH=$PATH:/usr/java/j2sdk1.4.2_04/bin
#export JAVA_HOME=/usr/java/j2sdk1.4.2_04
#export CLASSPATH=/usr/java/j2sdk1.4.2_04/lib:$CLASSPATH:.
# ---6
#====================================================
#export JAVA_HOME=/usr/java/j2sdk1.4.2_04
#export PATH=$JAVA_HOME/bin:$PATH
#export CLASSPATH=/usr/java/j2sdk1.4.2_04/lib:$CLASSPATH
#====================================================I think this will work. java -classpath /serverData/studentAC/s001 HelloWorld
-
Hi, I have those errors on a simple compilation:
root@vasco:/home/vasco/workspace/HelloServlet/src/fr/chicoree/sample# javac -classpath /opt/jboss/lib/javax.servlet.jar -d ${BLD}WEB-INF/classes ${SRC}HelloServlet.java
/home/vasco/workspace/HelloServlet/src/fr/chicoree/sample/HelloServlet.java:7: cannot find symbol
symbol: class HttpServlet
public class HelloServlet extends HttpServlet{
^
/home/vasco/workspace/HelloServlet/src/fr/chicoree/sample/HelloServlet.java:8: cannot find symbol
symbol : class HttpServletRequest
location: class fr.chicoree.sample.HelloServlet
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
/home/vasco/workspace/HelloServlet/src/fr/chicoree/sample/HelloServlet.java:8: cannot find symbol
symbol : class HttpServletResponse
location: class fr.chicoree.sample.HelloServlet
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
3 errors
As you can see I specified the classpath and everything else.........what is the problem??!
It also compiled yesterday with no pb and now I got problems....bizzarwell some things to check then.
- does said jar still exist at that precise location?
- do you have the rights to read that file as your current user?
- can you open the jar with a zip tool?
It might pay off to use a tool like ANT to build your code by the way, at least you'll only have to configure your classpath, source and destination folders once and then forget about it. -
Classpath Problem (Using JSAPI)
Hi,
I using IBM Via Voice as a the implementation of the JSAPI on my system. I've downloaded the speech for java pack from IBM Alphaworks and put it in the directory of
c:\ibmjs
This gives you access to the speech packages for utilisation in your programs so I should be able to import javax.speech in my programs. However the system doesn't see these classes.
Heres my Autoexec...
path=%path%;c:\jdk1.3.1_01\bin;c:\ibmjs\lib;
CLASSPATH=%CLASSPATH%;c:\ibmjs\lib\ibmjs.jar;
I presume the whole thing is just a classpath problem, does anybody have any idea from the above paths where I am going wrong?i guess you have to put some of ibm's dll files coming with speech for java in the path (not classpath). it's not sufficient to have the directories in the path.
anyway, there come's an installation manual with speech for java which explaines all that. -
Fragment Bundle Classpath problems
Does anyone have any tips for solving classpath problems in fragment bundles? I'm getting a no-class-def that I can't explain.
I've used maven to create a fragment, hosted by com.day.crx.sling.server, to create a custom login. It needs to call a web service, so I've included httpclient-4.2.3.jar. I can see this jar listed on the deployed fragment's Bundle-ClassPath, via the osgi>bundle console. When I inspect the bundle that maven created, I can find this jar contained in the bundle jar, in the directory specified in the Bundle-ClassPath. I even oppened the httpclient jar to ensure that the offending class (org/apache/http/client/HttpClient) is there.
This is the first fragment that I've tried to build. Is there something I don't know about how they load classes?
Does anyone have any tips or tricks on solving osgi classpath problems? I read that felix has some tools, but I haven't found any documentation about them.I'm still not sure why the classes didn't load, but I have a solution to my problem - don't try to include the jars in the fragment bundle. I tracked down osgi-ready versions of the libraries that I needed and and installed them.
-
class HelloWorldApp {
public static void main(String[] args)
System.out.println("Hello World!"); // Display the string.
JarClassLoader jcl=new JarClassLoader("test-jcl.jar");
}i have above program code in HelloWorldApp.java file
this program is kept in directory /home/vipin/JCL/
in the same directory i have two jar file jcl.jar and test-jcl.jar
content of jcl.jar file is as
META-INF/
META-INF/MANIFEST.MF
jcl.properties
log4j.properties
xeus/
xeus/jcl/
xeus/jcl/AbstractClassLoader.class
xeus/jcl/ClasspathResources.class
xeus/jcl/Configuration.class
xeus/jcl/JarClassLoader.class
xeus/jcl/JarResources.class
xeus/jcl/JclObjectFactory.class
xeus/jcl/exception/
xeus/jcl/exception/JclException.class
and content of test-jcl.jar is as
META-INF/
META-INF/MANIFEST.MF
log4j.properties
xeus/
xeus/jcl/
xeus/jcl/test/
xeus/jcl/test/Test.class
and i am compiling my HelloWorldApp.java as
javac -classpath /home/vipin/JCL\ LIBRARY/jcl.jar HelloWorldApp.java
but it gives error as:
HelloWorldApp.java:7: cannot resolve symbol
symbol : class JarClassLoader
location: class HelloWorldApp
JarClassLoader jcl=new JarClassLoader("test-jcl.jar");
^
HelloWorldApp.java:7: cannot resolve symbol
symbol : class JarClassLoader
location: class HelloWorldApp
JarClassLoader jcl=new JarClassLoader("test-jcl.jar");what goes wrong with me?Vipin_Dahiya wrote:
but it gives error as:
HelloWorldApp.java:7: cannot resolve symbol
symbol : class JarClassLoader
location: class HelloWorldApp
JarClassLoader jcl=new JarClassLoader("test-jcl.jar");
^
HelloWorldApp.java:7: cannot resolve symbol
symbol : class JarClassLoader
location: class HelloWorldApp
JarClassLoader jcl=new JarClassLoader("test-jcl.jar");what goes wrong with me?"cannot resolve symbol" is the compiler's way of saying "I don't know what JarClassLoader is!" You need to import JarClassLoader so that you can use it in your program.
Remember to use the full name of the class in your import statement. And make sure whatever jar file it lives in is included as part of the classpath you use when compiling the program. -
Javac -classpath / -sourcepath does not work ?
when i call javac in the current directory (where the java source files within subdirectories for package names) the compilation works. but when i go one directory up and want to use the -classpath or the -sourcepath options, i just get errors:
D:\TEMP\Java>javac -classpath ./examples test/HelloWorld.java
error: cannot read: test/HelloWorld.java
1 error
D:\TEMP\Java>javac -sourcepath ./examples test/HelloWorld.java
error: cannot read: test/HelloWorld.java
1 errorRunning javac in the directory D:\TEMP\Java\examples works ...nope, the doc for javac clearly says:
"If the -sourcepath option is not specified, the user
class path is searched for source files as well as
class files. "
(see
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/ja
ac.html#options)Yes but this is in reference to dependent classes, as the page you referenced explains.
The basic format of javac isjavac source_fileIf the source file needs other user classes, then the classpath is searched for either .class files or .java files. -
Another simple classpath problem question
Hi All
Yes I know, there are a lots of questions about this matter, but I couldn't found a solution to my problem.
I have a simple program:
public class prueba {
public static void main(String[] args) {
System.out.println("Ahi va...");
}placed in /tmp/javier/prueba.java
After compiled, I've tried to run it from / and then problems started:
cd /
java /tmp/javier/prueba
Exception in thread "main" java.lang.NoClassDefFoundError: /tmp/javier/prueba (wrong name: prueba)
I said, ok...it could be a classpath problem...then:
java -cp /tmp/javier/ /tmp/javier/prueba
Exception in thread "main" java.lang.NoClassDefFoundError: /tmp/javier/prueba
Damn, another try...
java -cp .:/tmp/javier/ /tmp/javier/prueba
Exception in thread "main" java.lang.NoClassDefFoundError: /tmp/javier/prueba (wrong name: prueba)
Jesus Christ....may be the last slash....
java -cp .:/tmp/javier /tmp/javier/prueba
Exception in thread "main" java.lang.NoClassDefFoundError: /tmp/javier/prueba (wrong name: prueba)
Oh...no.... may be classpath to java classes..
java -cp .:/usr/java/j2sdk1.4.2_01/lib/jre/:/tmp/javier/ /tmp/javier/prueba
Exception in thread "main" java.lang.NoClassDefFoundError: /tmp/javier/prueba (wrong name: prueba)
Well, I don't know why this error happens....
Please, could somebody help me !!!
Thanks in advance...
<jl>It's not too early to start following the Sun coding
conventions for Java:
http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.
tmlHi
thanks for your reply.
Yes, I agree. I use conventions with my programs. But my real problem was with a real application and then I did quickly this simple code to help others to understand the problem and give a fast reply...
Let me know if that works. (It was fine on my
machine.) - MODYes it works fine, thanks.... and Damn...Murphys law again, the only option I didn't tried is the solution to my problem... :)
Thanks again... -
Classpath problems in EAR packaging?
I try to access an EJB from a JSP. The JSP resides in web.war and the bean is in ejb.jar, and both of these are packaged together in an ear.
I get a compile error when I try opening a JSP. I've had this problem in all my attempts to use my bean classes from JSP.
My browser reports that the compiler cannot find the beans package. I have servlets within the war-file that are able to find the beans package, but the JSPs aren't.
My ear-file contains 3 files
ejb.jar
web.war
META-INF\MANIFEST.MF
The manifest classpath points to ejb.jar and web.war
My guess is that this has something to do with the way this is deployed by GlassFish.
The application is deployed in the
domains\mydomain\applications\j2ee-apps\myear\
This directory contains the expanded files:
ejb_jar\
web_war\
META-INF
So the Java classes under web_war\ are able to see the Java classes under ejb_jar\ (i.e. my servlets)
However; when GlassFish creates Java files from the JSPs and then tries to compile them, these files are placed under
domains\mydomain\generated\jsp\j2ee-apps\myear\web_war\org\apache\jsp\jsp
This might be correct for all I know, but apparently the compiler is unable to find the Java classes located under the mydomain\applications\.. directory when compiling classes located under the mydomain\generated\.. directory. There are no other files from my ear anywhere in the "generated" directory.
So to me this seems to be some kind of classpath problem, as the compiler cannot find the needed files.
Does this make any sense to anyone?
PS
In my ear, the JSPs are placed in the web.war. The war file looks like this:
jsp\
myjsp.jsp
META-INF
MANIFEST.MF
WEB-INF
web.xml
lib\
mylib.jarThanks
\\MariusMarius,
If you want communicate the bean you have to do following things.
. Create a factory for the correct protocol
. Obtain a Home
. Use the Home to create stubs to the remote object
So you want to call the Home and Remote interfaces to access the bean. When you run the client program, it will create the remote object that time it has to search the Home and Remote interfaces. So you have included those files for references in following location
WEB-INF/classes
-- <Home Interface File Name>.class
-- <Remote Interface File Name>.class
Or
WEB-INF/lib
-- <Bean Jar file name>.jar
I think you will understand.
-Mani -
JDBC and Classpath problems on OpenVMS
Hello,
I'm working on an OpenVMS server and I got a simpler Java application that needs to establish a connection to an Oracle database, the application works perfectly well on Windows but when I moved to OpenVMS I got some problems with the oracle driver.
I believe I�m using the correct driver, I already checked on the oracle site according to my java version (1.4.2) and my database version (oracle 9i 9.2.0.7.0)
This is the error:
$java -jar miss.jar "DnBProcess"
About to start loading parameters for the MISS Proxy.
Successfully load parameters for the MISS Proxy.
About to load interface settings for DnBProcess
Settings for DnBProcess succesffully loaded.
About to load interface DnBProcess
About to start loading parameters for DnB Interface.
Successfully load parameters for DnB Interface.
Interface DnBProcess succesffully loaded.
About to execute interface DnBProcess
Connecting to the database...
java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
at miss.DnBProcess.ExecuteQueryToFile(DnBProcess.java:85)
at miss.DnBProcess.Execute(DnBProcess.java:178)
at miss.Proxy.ExecuteInterface(Proxy.java:160)
at miss.Proxy.main(Proxy.java:207)
I know is a classpath problem, and my classpath on VMS looks like this:
define JAVA$CLASSPATH .,SYS$COMMON:[JAVA$142.LIB]TOOLS.JAR,SYS$COMMON:[JAVA$142.LIB]DT.JAR,SYS$COMMON:[JAVA$142.JRE.LIB]RT.JAR, USER1:[MONTEALEGRE.TEST.LIBS]OJDBC14.JAR,USER1:[MONTEALEGRE.TEST.MISS.LIBS]OJDBC14.JAR,[]
As you can see I added the �ojdbc14.jar� in different folders but my application seems not to find it.
Does anyone know how to set the classpath properly on VMS? Or maybe give me some tips that could lead me to find a solution to this problem.
Thanks.
Ileana.I would try googling for OpenVMS classpath. Unfortunatley the first result is this thread but there are a bunch of resources from IBM and HP listed and maybe they can help you.
-
hi everyone:
this is a bit embarassing, as I have been using java for some time, but I recently came across a classpath conceptual difficulty.
My understanding was that 'javac' uses classpath to find the path to any classes referenced in a target for compilation. However, I couldn't come up with any concrete rationale for using an additional classpath for 'java', the JVM command, when developing your own applications (I can see its importance for third party classes).
Doesn't javac encode the classpath passed to it in the compiled class file itself? (I figured this because even if I do not specify a classpath to the 'java', the program still executes fine). If this is true, then the only way I see the 'java' classpath being useful is if you were to change around the location of the class files after compilation.
Any thoughts would be greatly appreciated.Btw, there is no distiction between java and javac
classpaths. They're both the classpath.only difference i see there could be, is that, for
javac you tell the path to your .java file that
need's to be compiled, and for java you tell the name
of class whose main() method it should run (or you
tell which .jar file to execute)That's not relevant here. Classpath is used the same way for both of them. Classpath has nothing to do with finding a .java file to compile.
The only difference, I think, is that I think by default, the directory holding the package root of any .java file given as an arg to javac is implicitly added to the classpath. I'm not sure about that though.
>
so in some cases you would need to include "." in
your classpath for execution, but would not need to
include it for compilation.
just my 2 cents -
I have some jar files in folder .\lib
To include those jar files, for compiling I use
set classpath=.;%classpath%;
javac -classpath .\lib *.java
For running I use,
set classpath=.;%classpath%;
java -cp .\lib\*.jar; Application
As far as I know, if you use javac -classpath OR java -cp, you are actually replacing your original classpath, with what you are speicfying now with -classpath OR -cp.
But I what I want to do is use to those jar files in my classpath and in addition also those in my folder .\lib
Somehow they do not work. Any ideas? ThanksI think one of the following will work.
javac -classpath .;.\lib\jar1.jar;.\lib\jar2.jar;%classpath% *.java
or
set myjars=.\lib\jar1.jar;.\lib\jar2.jar;<etc.>
javac -classpath .;%myjars%;%classpath% *.java
Maybe you are looking for
-
[Solved] Problem with stunnel and nntp
I'm trying to encrypt nntp for pan. I already have it encrypted for sabnzbd, so I know that at least I have the server info correct. I've read a few different guides to getting stunnel going for nntp, but it seems like I'm missing something. Here's
-
Problems 1. One of the albums I have on my ipod is duplicated, the duplication is grey and it will not let me delete it although it does not play on my ipod or on itunes either 2. I cannot delete songs off my ipod from itunes, I have to go on my ipod
-
In I tunes store how do I delete old user ID?
In ITunes store- how do I delete old user ID?
-
PowerPoint to Keynote Conversion
Keynote seems to convert PowerPoint slides with the .ppt and .pptx suffixes, but not the macro-enabled .pptm suffix. Is there a work around?
-
XSU XSLT and using xsl:include href=""
I'm runing XDK 9.2 on an 8.1.7.4 database. I'm trying to transform the output of the XSU into a flat text file using a set of XSLT files. The main xslt includes the other xslt template files and then calls their templates by name as needed for differ