compiler java help

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Aug 2007
Posts: 14
Reputation: w32.sysfile is an unknown quantity at this point 
Solved Threads: 0
w32.sysfile w32.sysfile is offline Offline
Newbie Poster

compiler java help

 
0
  #1
Aug 31st, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,415
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 256
Moderator
masijade's Avatar
masijade masijade is online now Online
Nearly a Posting Maven

Re: compiler java help

 
0
  #2
Aug 31st, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 14
Reputation: w32.sysfile is an unknown quantity at this point 
Solved Threads: 0
w32.sysfile w32.sysfile is offline Offline
Newbie Poster

Re: compiler java help

 
0
  #3
Aug 31st, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 80
Reputation: lookof2day is an unknown quantity at this point 
Solved Threads: 10
lookof2day lookof2day is offline Offline
Junior Poster in Training

Re: compiler java help

 
0
  #4
Sep 1st, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 14
Reputation: w32.sysfile is an unknown quantity at this point 
Solved Threads: 0
w32.sysfile w32.sysfile is offline Offline
Newbie Poster

Re: compiler java help

 
0
  #5
Sep 1st, 2007
Originally Posted by lookof2day View Post
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??
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,200
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 486
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: compiler java help

 
0
  #6
Sep 1st, 2007
Originally Posted by w32.sysfile View Post
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.
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 80
Reputation: lookof2day is an unknown quantity at this point 
Solved Threads: 10
lookof2day lookof2day is offline Offline
Junior Poster in Training

Re: compiler java help

 
0
  #7
Sep 2nd, 2007
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/.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 14
Reputation: w32.sysfile is an unknown quantity at this point 
Solved Threads: 0
w32.sysfile w32.sysfile is offline Offline
Newbie Poster

Re: compiler java help

 
-1
  #8
Sep 2nd, 2007
Originally Posted by peter_budo View Post
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??
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 14
Reputation: w32.sysfile is an unknown quantity at this point 
Solved Threads: 0
w32.sysfile w32.sysfile is offline Offline
Newbie Poster

Re: compiler java help

 
0
  #9
Sep 2nd, 2007
Originally Posted by lookof2day View Post
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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC