Javac can't read filename.java
Hi
my problem is that javac can't read filename.java
i have saved the source code as filename.java under text document file type and i kept the capitalization the same for the[i] filename and classname but i am still having this error message: "error : can't read : filename.java" .
does that have anything to do with windows xp that i am using or there is absolutely something else that prevents javac from reading and compiling the file?
please help
Kind regards
Nour
The only 2 reasons that I can figure out why you are getting this error is either because your java file has not been properly named ie. filename.java or else then it is not in the same location ie directory from where you are trying to run your compiler.
Thus you need to run the compiler from the directory that contains your java source file so it really does'nt matter where you have saved your java file on the machine as long as your path is set to your j2sdk /bin Just cd your way to that directory where you have the java file and run the compiler javac
Similar Messages
-
How can we read filenames from a specific folder
Hi forum,
I have a situation that, there are several files coming daily in a specific folder.
I want to read filenames from that folder and want to get that filename in a variable.
That filename contains account nos. which I need for further processing.
Now, how can we read filenames from a specific folder with using Oracle PL/SQL Procedure?
Please suggest.
Thanks & regards,
KiranIf you are on 10g (not sure which exact release I'm afraid) you might look at Chris Poole's XUTL_FINDFILES that lists the files in a directory using PL/SQL and DBMS_BACKUP_RESTORE.SEARCHFILES (all a bit undocumented as it seems to be provided as part of rman).
The conventional (i.e. supported) approach is to use a Java stored procedure - there is an example on AskTom.
Message was edited by:
William Robertson -
Javac error: Can't read my .java-file
Hi,
sorry for my stupid question, but I have problems compiling my java code.
Before, I used NetBeans to compile the code and I had no problems with it. Now I have to use the javac command (with the same *.java-files) and it does not work.
It's running on Linux. In my current working directory, I have the file
image/transfer/smallserver/RequestProcessor.java
So I type
javac image.transfer.smallserver.RequestProcessor.java but I get this error:
error: can't read: image.transfer.smallserver.RequestProcessor.javaPlease, can anyone tell me, what's wrong with this?
Thank you for your help
SusanneI set all possible classpathes. It makes no difference.
If I try it a different way, I get other errors concerning the files I want to import. These files are located in image/transfer/client.
I tried to use smallserver as working directory, simply with the command
javac RequestProcessor.javaI get
Class image.transfer.client.ImageObject not found in importI tried it with the same working directory as before with "/" instead of "." in the path name. I get
error: Invalid class file format: ./image/transfer/client/ImageObject.class, wrong version: 46, expected 45and addionally the message from above (ImageObject not found) -
Help! - javac can't read my files
I have got the javac compiler to run, but it reports "Can't Read" my sample program file. I saved the file as a text document in Notepad (in Windows 95) but it changes my filename "BigDebt.java" to "BigDebt.java.txt". How do I save the files as .java files? Is this why the compiler can't read them or is the problem something else. Help!!!
Manually delete the .txt extension and try again. By default, Notepad appends .txt to all file save names you specify- I'm not sure how to change this. Perhaps try another editor such as Write (be sure to save as text)?
Also be sure to use the full file name with javac (including the .java extension). -
Read Filename form Adapter-Specific Message Attributes in Java Mapping
Hi,
I have scenario File to Mail adapter. How can i read filename from Adapter-Specific Message Attributes
in java mapping.
Thank you and Best regards
FernandHello Fernand,
Are u using DOM or SAX parser?
In any case just put the Dynamic config code in the execute function or the other option is to define it as a private functionand call it in the execute,My personal advice would be the former.
Just put this code in ur java mapping
As fellow sdn ers have mentioned there is no need of the container method,just initialise the set param method and use it in the dynamice config code as follows
public class YourClass implements StreamTransformation
private Map map;
public void setParameter(Map param)
map = param;
public void execute(InputStream in, OutputStream out) throws StreamTransformationException
DynamicConfiguration conf =(DynamicConfiguration) map.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey KEY_FILENAME =DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
// read value
File = conf.get(KEY_FILENAME);
Now just call File in the mapping program,
Should help u out
Regards,
Tauseef -
Javac "error: cannot read ..." windows 2000
I have installed jdk1.4.1 on my ibm with windows 2000. Whenever I try to compile a program, I get the message "error: cannot read: filename.java 1 error" Please let me know where I am making a mistake. Thank you.
No, you place the "" around the name when you save it. This prevents the .txt from being added to the name. This won't allow it to be compiled. I "solved" the problem another way by saving it with All Files and I type in filename.java. This works fine, but I do wonder why the .txt is added on my Windows 2000 machine, but not my Windows XP machine.
-
after vs 6 upgrade. my outlook exchange site loads, but can't maneuver within page. when I click on something it won't move, but locks up and an error message comes up mentioning java problem...but can't read it all as the page is locked. needs to x out and reload.
its the web page version of outlook exchange. there may also be a couple of other sites..after it loads, can't click on anything..no response....checked for latest version of java...and it verified I have latest.
never happended beforeWhaoo,
Looks like all I needed to do was ask the question and I would answer it.
It is definitely the outlook 2013 calendar item that had the new status. Even though I changed the item to a valid status, I needed to completely remove the item and add it back in with a valid legacy status from the start.
-The Steve -
Can't read a text file using java
Hi All
I am trying to read a log file.
ProgramA keeps updating the log file, while my program ProgramB reads it.
For some readson my ProgramB is not able to read the last two lines in the log file. If I run the program in debug mode it is reading all the lines.
This is having me frustrated.
Please let me know if there is a way to read entire contents.
Here is how I am reading the files ( 2ways)
private static String readFileAsString(String filePath)
throws java.io.IOException{
StringBuffer fileData = new StringBuffer(1000);
FileReader fr = new FileReader(filePath);
BufferedReader reader = new BufferedReader(fr);
char[] buf = new char[1024];
int numRead=0;
while((numRead=reader.read(buf)) != -1){
String readData = String.valueOf(buf, 0, numRead);
fileData.append(readData);
buf = new char[1024];
reader.close();
fr.close();
return fileData.toString();
* Fetch the entire contents of a text file, and return it in a String.
* This style of implementation does not throw Exceptions to the caller.
* @param aFile is a file which already exists and can be read.
static public String readFileAsString(String filePath) {
//...checks on aFile are elided
StringBuffer contents = new StringBuffer();
//declared here only to make visible to finally clause
BufferedReader input = null;
try {
//use buffering, reading one line at a time
//FileReader always assumes default encoding is OK!
input = new BufferedReader( new FileReader(filePath) );
String line = null; //not declared within while loop
* readLine is a bit quirky :
* it returns the content of a line MINUS the newline.
* it returns null only for the END of the stream.
* it returns an empty String if two newlines appear in a row.
while (( line = input.readLine()) != null){
contents.append(line);
contents.append(System.getProperty("line.separator"));
catch (FileNotFoundException ex) {
ex.printStackTrace();
catch (IOException ex){
ex.printStackTrace();
finally {
try {
if (input!= null) {
//flush and close both "input" and its underlying FileReader
input.close();
catch (IOException ex) {
ex.printStackTrace();
return contents.toString();
}If you're using JDK 5 or later, you could use the Scanner class for input information. See below:
try {
Scanner reader = new Scanner(new File("C:\\boot.ini"));
StringBuilder sb = new StringBuilder();
while (reader.hasNextLine()) {
sb.append(reader.nextLine());
sb.append(System.getProperty("line.separator"));
System.out.println(sb.toString());
} catch (FileNotFoundException e) {
e.printStackTrace();
} -
I had downloaded some junk and screwed up my registry and now can not read java appleates.Is there a simple task to get my java to work?
A) reinstall JRE
B) unless your after International language support, this isnt the right forum for your question. -
How can i read a document from a scanner machine in java
I am building a application and i want to read the document from the scanner
how can i read a document from a scanner machine in java
So pls help me on this issueProbably not via a network.
http://www.javaworld.com/javaworld/jw-07-2002/jw-0726-twain.html -
How to read the Java source code (in Netbeans)
I use OS X10.5.5, NetBeans 6.1 and JSE 6 on a 64 bit mac.
When I downloaded NB6.1 it had JSE 5 as it's default (and only) java platform. I ran Software Update to get Java 6 from Apple, used the Java Prefrences utitlity to set JSE6 as default. In NB I added the JDK6 platform, registered the JDK6 javadocs and noticed that I also have the option of registering the Java source code.
I have three questions:
1) How do I make JDK6 the default in NetBeans. The JDK5 keeps being default after I did the steps above and I don't see anywhere to change that.
2) How do I read the Java 6 source code? I can see sun provides [source code| http://download.java.net/jdk6/] for their supported platforms. I dont see Apple doing the same for its JDK port. What would I need to do to get to read the java SE6 sources? or is it actually hiding somewhere in the /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home hierarchy?
3) Where does the JVM look for the binary code to run when I make a call to, say java.util.ArrayList or any other library. In my naivety I would have assumed it would be a .class file somewhere in the java Home folder, but I don't see anything like it.
thanks in advance,
chrisThis is taken from the help included with netbeans. In response to question 1.
By default, the IDE uses the version of the Java SE platform (JDK) with which the IDE runs as the default Java platform
for compilation, execution, and debugging. You can view your IDE's JDK version by choosing Help > About and clicking the
Detail tab. The JDK version is listed in the Java field.
You can run the IDE with a different JDK version by starting the IDE with the --jdkhome jdk-home-dir switch on the command line
or in your IDE-HOME/etc/netbeans.conf file. For more information, see IDE Startup Parameters.
In the IDE, you can register multiple Java platforms and attach Javadoc and source code to each platform. For example, if you
want to work with the new features introduced in JDK 5.0, you would either run the IDE on JDK 5.0 or register JDK 5.0 as a
platform and attach the source code and Javadoc to the platform.
In , you can switch the target JDK in the Project Properties dialog box. In , you have to set the target JDK in the Ant script itself,
then specify the source/binary format in the Project Properties dialog box.
To register a new Java platform:
Choose Tools > Java Platforms from the main window.
Click New Platform and select the directory that contains the Java platform. Java platform directories are marked with a
in the file chooser.
Use the Sources and Javadoc tabs to attach Javadoc documentation and source code for debugging to the platform.
Click Close.
To set the default Java platform for a standard project:
Right-click the project's root node in the Projects window and choose Properties.
In the Project Properties dialog box, select the Libraries node in the left pane.
Choose the desired Java platform in the Java Platform combo box.
Switching the target JDK for a standard project does the following:
Offers the new target JDK's classes for code completion.
If available, displays the target JDK's source code and Javadoc documentation.
Uses the target JDK's executables (javac and java) to compile and execute your application.
Compiles your source code against the target JDK's libraries.
If you want to register additional Java platforms with the IDE, you can do so by clicking the Manage Platforms button.
Then click the Add Platform button and navigate to the desired platform.
To set the target Java platform for a free-form project:
In your Ant script, set the target JDK as desired in the javac, java, and javadoc tasks.
Right-click the project's root node in the Projects window and choose Properties.
In the Sources panel, set the level of JDK you want your application to be run on in the Source/Binary Format combo box.
When you access Javadoc or source code for JDK classes, the IDE searches the Java platforms registered in the
Java Platform Manager for a platform with a matching version number. If no matching platform is found, the IDE's default platform is used instead.
See Also
Managing the Classpath
Declaring the Classpath in a Free-Form Project
Stepping Through Your Program
Legal Notices -
Having alot of trouble in file reading in java
i dont know. but i feel really bad that Java is a very good OOP language and i suck big time (not very bad but got frustrated) in reading and writing files. some of the time i have accomplish my task with the help of forums. anyways first i would like to ask 2 questions and then i will state my problem. say for instance if i have a file with name amount and dollars. how can i read it?
i know i can use string regex split method in order to split the line but how can i create a method to do some changes in the text file like i have a name, bank account # and amount to deposit in the text file. my question is how can i declare my method to read (Name) first column and price second column and amount to deposit the third colum?
Secondly if i have a text file and i would like to replace all <<A>> with the name and <<G>> with the age. if i wanted to do without reading a file no problem create a string and then use the replaceAll method ("<<A>>", "Jaan") but for some reason i can't do it when i read a file. yes i am searching on google to get more understanding in reading file. but anyone care to explain wil be great. God bless you my Son.
import java.io.*;
import java.util.*;
class ReadData {
private Scanner s;
private static final String EMPTY_STRING = "";
private String line1;
private static String lineTerminator = System.getProperty("line.separator");
public static void main(String[] args) throws IOException {
ReadData read = new ReadData();
read.start();
public ReadData() {
s = new Scanner(System.in);
public void start() throws FileNotFoundException, IOException {
System.out.println("Enter the file name");
try {
String name = s.next();
openFile(name);
catch (FileNotFoundException e) {
e.printStackTrace();
catch (IOException e) {
e.printStackTrace();
public String openFile(String filename) throws FileNotFoundException, IOException {
String line;
String line2;
StringBuffer document = new StringBuffer(EMPTY_STRING);
File inFile = new File(filename);
FileReader fileReader = new FileReader(inFile);
BufferedReader bufReader = new BufferedReader(fileReader);
while(true) {
line = bufReader.readLine();
if(line==null) break;
document.append(line + lineTerminator);
System.out.print(document.toString());
return document.toString();
}i dont know. but i feel really bad that Java is a
very good OOP language and i suck big time (not very
bad but got frustrated) in reading and writing files.
some of the time i have accomplish my task with the
help of forums. anyways first i would like to ask 2
questions and then i will state my problem. say for
instance if i have a file with name amount and
dollars. how can i read it?Just like you'd read any other file. How you interpret what you've read depends on the specific format of the file, which you've provided no information about.
i know i can use string regex split method in order
to split the line but how can i create a method to do
some changes in the text file like i have a name,
bank account # and amount to deposit in the text
file. my question is how can i declare my method to
read (Name) first column and price second column and
amount to deposit the third colum? What do you mean? You want to read the entire first column, from all lines, then the entire second column, etc.? Unless you know the length of each line ahead of time so you can use RandomAccesFile, you can't do that. If that's not what you mean, then please clarify.
Secondly if i have a text file and i would like to
replace all <<A>> with the name and <<G>> with the
age. if i wanted to do without reading a file no
problem create a string and then use the replaceAll
method ("<<A>>", "Jaan") but for some reason i can't
do it when i read a file.
Create a tmp file.
For each line {
Read a line.
Do the replacement on the string you read.
Write the new line out to the temp file
rename the temp file to the original
anyone care to explain wil be great. God bless you my
Son.I'm not your son. Keep your god away from me. -
How can I read mail attachment for making it to the payload?
Hi everybody,
in the following my scenario:
I have an incoming message with attachment by the mail sender adapter using PayloadSwapBean (because of other messages I have to use the bean). I want to send this attachment by using the mail receiver adapter to fix E-mail-address keeping the FromMailAddress, the MailSubject and the FileName
without the metadata as additional attachment.
I have found a thread where it is explained how to handle "payload as mail attachment and dynamic filename" by java-mapping. So far so good. My question is: How can I make my attachment to be the payload? How can I read the attachment by java-mapping?
Thanks for help.
Reagrds,
Sebastian LinkeUSe payloadSwapBean for this to swap your payload and attachment
/people/michal.krawczyk2/blog/2005/12/18/xi-sender-mail-adapter--payloadswapbean--step-by-step
Rajesh
Edited by: Rajesh on Feb 5, 2009 5:29 PM -
How can i apply this java program for a jsp page?
import java.io.*;
import java.util.*;
public class FileProcessing
//create a vector container for the input variables
Vector variables = new Vector();
//create a vector container for the constants
Vector constants = new Vector();
/*create a string expression container for the equation
as read from the file */
String expression = " ";
//create double result container for the final result
double result = 0;
public boolean processFile(String filename,String delim)
//index for values vector
int num_values = 0;
//index for constants vector
int num_constants = 0;
//current line being read from the external file.
String curline = " ";
//start reading from the external file
try
FileReader fr = new FileReader(filename);
BufferedReader br = new BufferedReader(fr);
while(true)
curline = br.readLine();
if(curline == null)
break;
//determine the type of current interaction
boolean variable = curline.startsWith("input");
boolean constant = curline.startsWith("constant");
boolean equation = curline.startsWith("equation");
boolean output = curline.startsWith("result");
//on input variables
if(variable)
StringTokenizer st = new StringTokenizer(curline,delim);
int num = st.countTokens();
int count=0;
while(st.hasMoreTokens())
String temp = st.nextToken();
if(count==1)
byte b[]= new byte[100];
System.out.println(temp);
System.in.read(b);
String inputval = (new String(b)).trim();
variables.add(num_values,inputval);
num_values++;
count++;
// on constant values
if(constant)
StringTokenizer st = new StringTokenizer(curline,delim);
int num = st.countTokens();
int count = 0;
while(st.hasMoreTokens())
String temp = st.nextToken();
if(count==1)
byte b[]= new byte[100];
System.out.println(temp);
System.in.read(b);
String cons = (new String(b)).trim();
constants.add(num_constants,cons);
num_constants++;
count++;
// on equation
if(equation)
StringTokenizer st = new StringTokenizer(curline,delim);
int num = st.countTokens();
int count = 0;
while(st.hasMoreTokens())
String temp = st.nextToken();
if(count==2)
this.expression = temp;
count++;
// now we are ready to evaluate the expression
if(output)
org.nfunk.jep.JEP myparser= new org.nfunk.jep.JEP();
myparser.setAllowAssignment(true);
for(int i=1;i<variables.size()+1;i++)
String name = "arg"+Integer.toString(i);
myparser.addVariable(name,new Double(variables.get(i-1)
.toString()).doubleValue());
for(int i=1;i<constants.size()+1;i++)
String name = "arg" +Integer.
toString(i+variables.size());
myparser.addConstant(name,new Double(constants.get(i-1).toString()));
//output is obtained as follows
myparser.parseExpression(expression);
result = myparser.getValue();
System.out.println("Assay value: "+result);
catch(Exception e)
System.out.println(e.toString());
return true;
public static void main(String[] args)
FileProcessing fp = new FileProcessing();
fp.processFile("input.eqn",":");
}//my text file name is: "input.eqn" (given below)
input:Enter Value1:arg1
input:Enter Value2:arg2
input:Enter Value3:arg3
constant:arg4
constant:arg5
Equation:arg1+arg2+arg3
result:how can i apply this java program for a jsp pagewhy do you want to do this ?
Your program reads from a file on the disk and formats based on a patterm.
Jsp is not intended for such stuff.
ram. -
Error: cannot read HelloworldApp.java
Hello
When I compile the HelloWorldApp.java program. I have this problem:
I get: error: cannot read HelloworldApp.java. What can I do?
In addition, How do I use the options? For example:
javac -g HelloworldApp.java
I get an error saying that I did not use well the flag g. Is the command bad written?.You post has different capitalization of the program name:
". . .compile the HelloWorldApp.java program. I have this problem:
I get: error: cannot read HelloworldApp.java.
Java is case-sensitive, make sure to capitalize correctly.
Open a cmd/command window in the directory that contains your .java file and do a "dir helloworldapp.java" command to verify the file exists with the correct name.
Read the documentation for the javac command to learn how to use the command options.
Maybe you are looking for
-
http://author.confirmit.com//isa/KTAYBTGOKOMVCAAHHMPIDXAQKVOTBALO/srinu/Mozilla%20Firefox_trouble1.htm Please find this link. I am getting this message frequently.
-
ITunes CONSTANTLY freezing the computer
For about a week now iTunes just won't stop freezing my computer. Anything I do (listen to a song, download a song or update my iPhone/iPod), it will freeze. The computer starts making noises and eventually i have to shut off the computer and restart
-
Service Security and governance.
Hi Gurus, I have two questions with respect to enterprise services for which i can't find any answers till now - 1. Is Single sign-own the only option for enabling security in enterprise services. If yes or no, how do we enable them. 2. Can we enable
-
Clearing resource bundle cache - can it be done? how?
How can I refresh/clear the resource bundle cache? I'm using JDK1.6 (under Tomact), been trying to use the ResourceBundle.clearCache(); method as indicated in the [International Enhancements in Java SE 6|http://java.sun.com/developer/technicalArticle
-
ICP dimension conflict with HFM
Hi Guys, I need your help for the following, I am using FDM 11.1.1.3 together with HFM 11.1.1.3.50. Now, in HFM the ICP dimension has been set up as follows (for which I have been told this is not best practice): Parent: [ICP TOP] Child1: [ICP NONE]