| | |
Beginner problem compiling with javac
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2006
Posts: 2
Reputation:
Solved Threads: 0
Hi I am trying to compile a program from a tutorial I am doing.
The program is titled myprogram.java and is located in the c:\src> directory.
When I use the command c:\src>javac myprogram.java I get the following errors.
myprogram.java:1: <identifier> expected
class
^
myprogram.java:8: '>' expected
^
2 errors
and when I try
c:\src> javac src\myprogram.java
I get:
error: cannot read: src\myprogram.java
1 error
I am using windowsXP and jdk1.5.0_06
I have set Path and CLASSPATH in my enviromental variables.
I am sure this is a simple problem, but if anybody would help I would really appreciate it.
Thanks.
The program is titled myprogram.java and is located in the c:\src> directory.
When I use the command c:\src>javac myprogram.java I get the following errors.
myprogram.java:1: <identifier> expected
class
^
myprogram.java:8: '>' expected
^
2 errors
and when I try
c:\src> javac src\myprogram.java
I get:
error: cannot read: src\myprogram.java
1 error
I am using windowsXP and jdk1.5.0_06
I have set Path and CLASSPATH in my enviromental variables.
I am sure this is a simple problem, but if anybody would help I would really appreciate it.
Thanks.
•
•
Join Date: Mar 2006
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Narue
Can you post the code as well?
class myprogram {
public static void main(String[] args) {
System.out.println(
"Eureka, I can put Java on my resume.");
}
}
but as soon as i changed it to
public class myprogram {
public static void main(String[] args) {
System.out.println(
"Eureka, I can put Java on my resume.");
}
}
it worked!
Now my new problem when I type
c:\src>java myprogram
i get
Exception in thread "main" java.lang.NoClassDefFoundError: myprogram
Thanks again.
probably a classic case of not adding the current directory to the classpath.
"java -cp . myprogram" should do the trick until you learn to use proper naming conventions for your classes and members.
"java -cp . myprogram" should do the trick until you learn to use proper naming conventions for your classes and members.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
•
•
Join Date: May 2005
Posts: 82
Reputation:
Solved Threads: 1
•
•
•
•
Originally Posted by jwenting
bad idea. What you're saying is "don't learn to use your tools, here's a quick hack for the terminally lazy and stupid".
![]() |
Other Threads in the Java Forum
- Previous Thread: How do i change/get my port number?
- Next Thread: Connecting modem via java
Views: 4675 | Replies: 11
| Thread Tools | Search this Thread |
Tag cloud for Java
-xlint android api apple applet application arguments array arrays automation binary blackberry block bluetooth chat class classes client code compile component database developmenthelp draw eclipse encode error event exception file fractal game gameprogramming givemetehcodez graphics gui helpwithhomework html ide image input integer iphone j2me j2seprojects java javac javaprojects jmf jni jpanel julia lego linux list loop loops mac map method methods mobile netbeans newbie notdisplaying number object online oracle print problem program programming project recursion scanner screen server set singleton size sms socket sort sql string swing system template test textfields threads time title transfer tree tutorial-sample update windows working






