LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-23-2006, 01:45 AM   #1
cdc5205
LQ Newbie
 
Registered: Jan 2006
Distribution: Ubuntu 7.04
Posts: 21

Rep: Reputation: 16
javac command not compiling


I've just began to use java, and I'm pretty sure my code is correct, but when trying to compile i get this error:

javac hello.java
error: cannot read: hello.java
1 error

or
javac /home/Chad/java/hello.java
error: cannot read: /home/Chad/java/hello.java
1 error


I'm in the correct directory, i have read rights. I also tried it as super user. I'm using SuSE 10, I installed the SDK through YaST
my java -version is:
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)

Do I need to set a path directory? Any help would be appreciated. thanks.
 
Old 01-23-2006, 02:59 AM   #2
deroB
Member
 
Registered: Dec 2005
Location: Sydney, Australia
Distribution: Arch Linux
Posts: 208

Rep: Reputation: 30
It sounds like you need to set your classpath to search the current directory.
easiest way to do this is to compile with:

Code:
javac -cp . hello.java
good luck
 
Old 01-23-2006, 12:30 PM   #3
cdc5205
LQ Newbie
 
Registered: Jan 2006
Distribution: Ubuntu 7.04
Posts: 21

Original Poster
Rep: Reputation: 16
I tried your suggestion and i got an invalid flag error, but I used

javac -classpath . hello.java
error: cannot read: hello.java
1 error
 
Old 01-23-2006, 01:50 PM   #4
deroB
Member
 
Registered: Dec 2005
Location: Sydney, Australia
Distribution: Arch Linux
Posts: 208

Rep: Reputation: 30
Must be a permission problem....
try changing the permissions of hello.java to enable read and write.

Code:
chmod 666 hello.java

Last edited by deroB; 01-23-2006 at 02:00 PM.
 
Old 01-23-2006, 03:20 PM   #5
cdc5205
LQ Newbie
 
Registered: Jan 2006
Distribution: Ubuntu 7.04
Posts: 21

Original Poster
Rep: Reputation: 16
Well when i tried to give permissions, i noticed that my file didn't containt the .java extension, and that was my problem. Can't believe i didn't notice that. Thank you for your help.
 
Old 01-23-2006, 03:47 PM   #6
deroB
Member
 
Registered: Dec 2005
Location: Sydney, Australia
Distribution: Arch Linux
Posts: 208

Rep: Reputation: 30
no worries.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash: javac: command not found??? MRAB54 Linux - Newbie 6 02-18-2015 08:18 AM
compiling using javac in vim on windows mineshvarmas Programming 1 01-20-2006 11:54 PM
-bash-- javac command not found nedian123 Programming 1 06-28-2004 04:16 PM
J2sdk problem Javac command not found CollestonPie13 Linux - Software 3 02-15-2004 11:30 AM
problem with javac command mekasrinu Programming 2 06-12-2001 07:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration