| | |
compiler java help
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
Read the "Getting Started" Tutorial. And don't save anything to the "bin" directory (or any other directory inside of the jdk directory).
Last edited by masijade; Aug 31st, 2007 at 5:01 am. Reason: typo
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Aug 2007
Posts: 80
Reputation:
Solved Threads: 10
Well you need to properly read the introduction of Java where authors of various books have mention how to compile and run your first program in Java.
Anyway, if you have compiled the .java source code to .class file, and you want to run it, then you need to verify whether java command is available in your PATH environment variable or not. Follow the steps given below:
1) Open a command prompt and type java.
2) If it says java not found and you have installed jdk/jre, then you need to manually set the PATH.
3) To manually set the PATH, type on your command prompt
set JAVA_HOME=C:\Program Files\Java\Jdk1.6.0_1
set PATH=%PATH%;JAVA_HOME
4) To execute cd to whatever directory your .class is present. Suppose it is present in D:\demo and .class is Hello.class
5) Then type java Hello
6) And you'll see your program is executing
7) In some cases, you might get an exception "NoClassFoundException" then you are required to set the CLASSPATH variable.
8) Type set CLASSPATH=.
9) Then type java Hello
//.means current working directory. So when searching for class, Java class loader will look into current working directory (D:\demo) and execute the Hello program
Anyway, if you have compiled the .java source code to .class file, and you want to run it, then you need to verify whether java command is available in your PATH environment variable or not. Follow the steps given below:
1) Open a command prompt and type java.
2) If it says java not found and you have installed jdk/jre, then you need to manually set the PATH.
3) To manually set the PATH, type on your command prompt
set JAVA_HOME=C:\Program Files\Java\Jdk1.6.0_1
set PATH=%PATH%;JAVA_HOME
4) To execute cd to whatever directory your .class is present. Suppose it is present in D:\demo and .class is Hello.class
5) Then type java Hello
6) And you'll see your program is executing
7) In some cases, you might get an exception "NoClassFoundException" then you are required to set the CLASSPATH variable.
8) Type set CLASSPATH=.
9) Then type java Hello
//.means current working directory. So when searching for class, Java class loader will look into current working directory (D:\demo) and execute the Hello program
•
•
Join Date: Aug 2007
Posts: 14
Reputation:
Solved Threads: 0
•
•
•
•
Well you need to properly read the introduction of Java where authors of various books have mention how to compile and run your first program in Java.
Anyway, if you have compiled the .java source code to .class file, and you want to run it, then you need to verify whether java command is available in your PATH environment variable or not. Follow the steps given below:
1) Open a command prompt and type java.
2) If it says java not found and you have installed jdk/jre, then you need to manually set the PATH.
3) To manually set the PATH, type on your command prompt
set JAVA_HOME=C:\Program Files\Java\Jdk1.6.0_1
set PATH=%PATH%;JAVA_HOME
4) To execute cd to whatever directory your .class is present. Suppose it is present in D:\demo and .class is Hello.class
5) Then type java Hello
6) And you'll see your program is executing
7) In some cases, you might get an exception "NoClassFoundException" then you are required to set the CLASSPATH variable.
8) Type set CLASSPATH=.
9) Then type java Hello
//.means current working directory. So when searching for class, Java class loader will look into current working directory (D:\demo) and execute the Hello program
you really dont understand..
i am making a compiler.and not compiling
any 1 can help me to run the class generated??
•
•
•
•
you really dont understand..
i am making a compiler.and not compiling
any 1 can help me to run the class generated??
Your first post sound as english is not your first language and you do not provide a proper explanation. Secondly only beginners really put any code in "bin" folder as they can't or do not want to figure out how to set up PATH and CLASSPATH for Java.
Your question "any 1 know how to run the generated class file??" sounds like begginer call for help. I hope that you learn from your mistake and next time provide good explanation.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Aug 2007
Posts: 80
Reputation:
Solved Threads: 10
Well for using Java Compiler API you can refer to the following link http://www.javabeat.net/javabeat/jav...iler_api_1.php.
But as you already told that you have succeeded in compilation and now wants to execute then simply use the java command.
If in case you want to write your own VM for running the compiled .class file then please refer to the following open source projects. They will help you get started:
1) OpenJDK
2) Apache Harmony
3) Kaffe from http://www.kaffe.org/.
But as you already told that you have succeeded in compilation and now wants to execute then simply use the java command.
If in case you want to write your own VM for running the compiled .class file then please refer to the following open source projects. They will help you get started:
1) OpenJDK
2) Apache Harmony
3) Kaffe from http://www.kaffe.org/.
•
•
Join Date: Aug 2007
Posts: 14
Reputation:
Solved Threads: 0
•
•
•
•
No need to be harsh this way.
Your first post sound as english is not your first language and you do not provide a proper explanation. Secondly only beginners really put any code in "bin" folder as they can't or do not want to figure out how to set up PATH and CLASSPATH for Java.
Your question "any 1 know how to run the generated class file??" sounds like begginer call for help. I hope that you learn from your mistake and next time provide good explanation.
•
•
Join Date: Aug 2007
Posts: 14
Reputation:
Solved Threads: 0
•
•
•
•
Well for using Java Compiler API you can refer to the following link http://www.javabeat.net/javabeat/jav...iler_api_1.php.
But as you already told that you have succeeded in compilation and now wants to execute then simply use the java command.
If in case you want to write your own VM for running the compiled .class file then please refer to the following open source projects. They will help you get started:
1) OpenJDK
2) Apache Harmony
3) Kaffe from http://www.kaffe.org/.
![]() |
Similar Threads
- Making A Java Compiler... In Java (Java)
- get path to java compiler (Java)
- Java Compiler (Java)
Other Threads in the Java Forum
- Previous Thread: Filing Problem
- Next Thread: Financial Information eXchange (FIX) protocol
| Thread Tools | Search this Thread |
-xlint android api applet application array arrays automation bi binary blackberry block bluetooth chat class classes client code compile compiler component database developmenthelp eclipse error exception fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui html ide image input integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loop loops mac map method methods mobile myregfun netbeans newbie notdisplaying number online page print problem program programming project qt recursion scanner screen server set singleton size sms sort spamblocker sql string swing system template textfields threads time title tree tutorial-sample update variablebinding windows working xor






