943,600 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 1731
  • Java RSS
Aug 31st, 2007
0

compiler java help

Expand Post »
i want to do a compiler but, now i am stuck in the compilation part,
suppose that i want to compile "cool.java" that is located in the bin directory, what shold i do??
help please
Similar Threads
Reputation Points: 9
Solved Threads: 0
Newbie Poster
w32.sysfile is offline Offline
14 posts
since Aug 2007
Aug 31st, 2007
0

Re: compiler java help

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
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Aug 31st, 2007
0

Re: compiler java help

thanks for replying
I have done the compilation part using the Java Compiler Api

but can any 1 know how to run the generated class file??

thanks
Last edited by w32.sysfile; Aug 31st, 2007 at 10:40 pm.
Reputation Points: 9
Solved Threads: 0
Newbie Poster
w32.sysfile is offline Offline
14 posts
since Aug 2007
Sep 1st, 2007
0

Re: compiler java help

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
Reputation Points: 16
Solved Threads: 11
Junior Poster in Training
lookof2day is offline Offline
83 posts
since Aug 2007
Sep 1st, 2007
0

Re: compiler java help

Click to Expand / Collapse  Quote originally posted by lookof2day ...
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??
Reputation Points: 9
Solved Threads: 0
Newbie Poster
w32.sysfile is offline Offline
14 posts
since Aug 2007
Sep 1st, 2007
0

Re: compiler java help

you really dont understand..

i am making a compiler.and not compiling

any 1 can help me to run the class generated??
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.
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 871
Code tags enforcer
peter_budo is offline Offline
6,653 posts
since Dec 2004
Sep 2nd, 2007
0

Re: compiler java help

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/.
Reputation Points: 16
Solved Threads: 11
Junior Poster in Training
lookof2day is offline Offline
83 posts
since Aug 2007
Sep 2nd, 2007
-1

Re: compiler java help

Click to Expand / Collapse  Quote originally posted by peter_budo ...
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.
feel so offended??
Reputation Points: 9
Solved Threads: 0
Newbie Poster
w32.sysfile is offline Offline
14 posts
since Aug 2007
Sep 2nd, 2007
0

Re: compiler java help

Click to Expand / Collapse  Quote originally posted by lookof2day ...
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/.
i have done the progrm, thanks
Reputation Points: 9
Solved Threads: 0
Newbie Poster
w32.sysfile is offline Offline
14 posts
since Aug 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Filing Problem
Next Thread in Java Forum Timeline: Financial Information eXchange (FIX) protocol





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC