...

View Full Version : a duplicate file name exists, or the file cannot be found



mazao
12-16-2011, 07:38 PM
class ThreadCan implements Runnable {
TempReader app = new TempReader();
public void run(){
// TODO Auto-generated method stub
if (app.init()){
System.out.println("Wait for read temperature from CAN");
app.readTempViaCAN();
}//if (app.init());
}
}
http://www.uppic.org/thumb-C0CC_4EEB9E0A.jpg (http://www.uppic.org/share-C0CC_4EEB9E0A.html)

Fou-Lu
12-17-2011, 08:53 AM
That screenshot is far to small; there is no way to read what is on there. Redirect the output to a file and post that instead.
I cannot see anything you are doing here that will cause the above error. You are not directly interacting with a filesystem. If the .readTempViaCAN is what is throwing the error, then you need to point it at something. I would expect that if this is the case though, that the method should contain no overload that allows nothing, so the code should fail to compile. You may be missing something else, such as an app.open type call to force open a resource manually.

mazao
12-17-2011, 10:03 AM
click on screenshot to full

Fou-Lu
12-17-2011, 10:12 AM
click on screenshot to full

The screenshot is a thumbnail. There is no option to increase its size as its already full. Post the output to a file.

mazao
12-17-2011, 10:44 AM
my code :

/* Create on: 16 July 2008 13:00:00
**/
class ThreadCan implements Runnable {
TempReader app = new TempReader();
public void run(){
// TODO Auto-generated method stub
if (app.init()){
System.out.println("Wait for read temperature from CAN");
app.readTempViaCAN();
}//if (app.init());
}
}


compile error :

ThreadCan.java:4:cannot resolve symbol
symbol: class TempReader
location : class ThreadCan
TempReader app = new TempReader();
^

ThreadCan.java:4:cannot resolve symbol
symbol: class TempReader
location : class ThreadCan
TempReader app = new TempReader();
^

2 errors
A duplicate file name exists, or the file
cannot be found.

I have 5 files can only pass compile 1 file other have same error problem
sourcecode
http://www.mediafire.com/?eujeu6vg6hcbxl3

Fou-Lu
12-17-2011, 06:25 PM
The problem is really simple, TempReader cannot be resolved. Make sure that you are compiling with the classpath added to include a location to resolve your imports to. TempReader has to be compiled first as well.

This tutorial is excellent for helping you set up a manual javac call: http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/javac.html
Alternatively (and my recommendation), use an IDE with a builtin precompile before run. Eclipse is what I use, although any IDE designed for java will have this functionality built in.

mazao
12-18-2011, 01:56 PM
emm I don't know how to add classpath to include a location to resolve.
I use build.bat compile, code
-----------------------------------------------------------------------------------
@echo off
REM Source files
set SRC= ThreadCan.java

mkdir output
C:\j2sdk1.4.2\bin\javac.exe -target 1.1 -bootclasspath C:\snap\classes -classpath . -d .\output %SRC%
C:\snap\bin\preverify -classpath C:\snap\classes -nofinalize -d output output
move output\*.class .
rmdir /s /q output

pause
------------------------------------------------------------------------
I have file TempReader.java that can pass compile get to TempReader.class
but my ThreadCan.java can't pass compile

I'm confused that I must include classpath or I must set add variable
because my code build.bat that have C:\snap\bin\preverify -classpath C:\snap\classes
about classpath

Can I download more classpath ?????

Fou-Lu
12-18-2011, 02:43 PM
Is ThreadCan and TempReader a part of the same package? If they are not, classpath has to include the path to TempReader's package level (the import will take care of the drill into the package). If they are the same package, and that package is default, a classpath of /path/to/.class/files/package should work just fine.
This is pretty old school too. You're compiling for a 1.1 version of Java. Java is currently at Java 7, so there is a high probability on more complex programs it will fail to compile since there will be many methods not available. Just ignore the target and let the version of javac determine what is best to compile for.

mazao
12-18-2011, 03:51 PM
now I try to use jdk1.7.0_02 compile TempReader.java that can pass compile on j2sdk1.4.2
but jdk1.7.0_02 can't pass compile

error compile :
TempReader.java:28:error:cannot access StringBuilder

System.out.println("Receive Event."); System.out.println("Frame received:"); System.out.print("ID: "+Integer.toHexString(cf.ID)); if (cf.extendedID) System.out.print("(extenedID)");
^

class file for java.lang.StringBuilder not found
A a duplicate file name exists, or the file cannot be found
----------------------------------------------------------------------------------

but work on j2sdk1.4.2 Why ?

Fou-Lu
12-18-2011, 04:32 PM
Are you sure you have your versions right? 1.4 won't compile a StringBuilder since it wasn't added until java 1.5. Methinks that error is complaining on a javac 1.4, not the 1.7.

mazao
12-18-2011, 04:46 PM
now I use 1.4 that can pass compile TempReader.java work done get TempReader.class

but you told me try to use 1.7 that can't pass compile have error:cannot access StringBuilder

error java1.7

I think i must use java1.4 and find solve error because work on TempReader.java

compile error :

ThreadCan.java:4:cannot resolve symbol
symbol: class TempReader
location : class ThreadCan
TempReader app = new TempReader();
^

ThreadCan.java:4:cannot resolve symbol
symbol: class TempReader
location : class ThreadCan
TempReader app = new TempReader();
^

2 errors
A duplicate file name exists, or the file
cannot be found.

Fou-Lu
12-18-2011, 05:44 PM
No, what I'm saying is that stringbuilder will not compile in 1.4. The class does not exist until 1.5, so that tells me your versions of javac are backwards.
So lets go back to square one. First and foremost, is ever required class imported? Is TempReader in a different package and provided the proper import?

mazao
12-19-2011, 09:44 AM
Thank a lot



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum