Code to generate java program
hello,
i am studying msc(information systems) 2 years course.
this is my first semister.i am doing prof\ject in java.
TITLE:Designing editor for java in java.
I want to know how to compile a program written in the editor.i will feel very much happy,if u could tell me the suggestion.And alse running the class file.
thanking you...
Take a gander at the java.lang.Runtime class - in particular the exec method. Invoke the compiler like you would on a DOS or Unix command line.
You'll have to use a ClassLoader to make the JVM load - or reload, if it's already known to the JVM - the resulting class file.
Similar Messages
-
Calling C code (exe ) from Java program
Hi all,
kindly help in giving a solution for calling C code (exe ) from Java program, i will be very thank full to u if any body can help in sending a code example
byeYou might need to consume the io operations on the Process...
An excerpt from java.lang.Process:
All its standard io (i.e. stdin, stdout, stderr) operations will be redirected to the parent process through three streams (Process.getOutputStream(), Process.getInputStream(), Process.getErrorStream()). The parent process uses these streams to feed input to and get output from the subprocess. Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock. -
Java code to read Java Program
Hi,
Is there any standard api to retrieve the java program's class name, method name, its parameter, code etc...
My req is to write a java program that takes any java programme file as input and returns the class name, method name, parameter name and type etc...
Thanks,
Santhosh.Take a look at the annotation processor atp in the standard Java toolkit. It provides a framework for scanning Java source files visiting types, fields etc.
Or you could get hold of javacc, which comes with an example schema for reading Java source. -
XML Schema Class Generator Problem compiling generated java programs
Hi,
I ran oracg on the po.xsd schema from X3Cs XML Schema Part 0: Primer which successfully generated the java codes. I ran into problems when I compile the generated classes. Here's what I'm getting:
C:\oracle\xml\xdk\demo\java\classgen\Po2>javac -classpath ".;C:\oracle\xml/lib/xmlparserv2.jar;C:\oracle\xml/lib/xschema.jar;C:\oracle\xml/l
ib/classgen.jar;.;C:\Program Files\VicunaJ521\java\lib\collections.jar;C:\Program Files\VicunaJ521\java\lib\vicunalite.jar;C:\Program Files\
XConverter\XConverter.jar;C:\Program Files\XConverter\IDLGenerator.jar; c:\jdk1.2.2\lib\dt.jar;c:\jdk1.2.2\lib\jvm.jar;c:\jdk1.2.2\lib\tools
.jar;c:\oracle\ora81\jdbc\lib\classes12.zip;c:\oracle\ora81\jdbc\nls_charset12.zip;C:\oracle\xml\lib\classgen.jar;C:\oracle\xml\lib\xmlparse
rv2.jar" *.java
.\types\PurchaseOrderType.java:75: Type expected.
public void addComment(null.Comment thecomment)
^
.\types\Items.java:141: Type expected.
public void addComment(null.Comment thecomment)
^
2 errors
Running the demo which comes with oracles version of po.xsd was OK. What's the difference between the po.xsd from oracle and the po.xsd from W3C? Are there any W3C recommendation for XML Schema not supported by Oracle's class generator?Which po.xsd do you use? Would you post it?
Thanks. Here's the copy of the po.xsd from the W3C website. (http://www.w3.org/TR/xmlschema-0/#po.xsd)
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:annotation>
<xsd:documentation xml:lang="en">
Purchase order schema for Example.com.
Copyright 2000 Example.com. All rights reserved.
</xsd:documentation>
</xsd:annotation>
<xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
<xsd:element name="comment" type="xsd:string"/>
<xsd:complexType name="PurchaseOrderType">
<xsd:sequence>
<xsd:element name="shipTo" type="USAddress"/>
<xsd:element name="billTo" type="USAddress"/>
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="items" type="Items"/>
</xsd:sequence>
<xsd:attribute name="orderDate" type="xsd:date"/>
</xsd:complexType>
<xsd:complexType name="USAddress">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="street" type="xsd:string"/>
<xsd:element name="city" type="xsd:string"/>
<xsd:element name="state" type="xsd:string"/>
<xsd:element name="zip" type="xsd:decimal"/>
</xsd:sequence>
<xsd:attribute name="country" type="xsd:NMTOKEN"
fixed="US"/>
</xsd:complexType>
<xsd:complexType name="Items">
<xsd:sequence>
<xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="productName" type="xsd:string"/>
<xsd:element name="quantity">
<xsd:simpleType>
<xsd:restriction base="xsd:positiveInteger">
<xsd:maxExclusive value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="USPrice" type="xsd:decimal"/>
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="partNum" type="SKU" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<!-- Stock Keeping Unit, a code for identifying products -->
<xsd:simpleType name="SKU">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d{3}-[A-Z]{2}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema> -
hello,
i am studying msc(information systems) 2 years course.
this is my first semister.i am doing prof\ject in java.
TITLE:Designing editor for java in java.
I want to know how to compile a program written in the editor.i will feel very much happy,if u could tell me the suggestion.And alse running the class file.
thanking you...Hi rajesh!
First you need a java development kit (jdk).
If you didn't get it yet you can download the actual version on this page (just search for "download").
If you've installed the jdk make sure that the path where you installed your jdk is set to your systems path value (windows)
you can put it in by editing your autoexec bat or by giving the following order to your dos box:
1.) PATH (returns the actual path settings)
2.) SET PATH old values, [...]\jdk\bin
After having done this you should reboot your system.
Now you can change the directory to your programs path and call:
JAVAC yourfile.java
this compiles your program
JAVA yourfile
(without any file extension!!) runs your program
It might be useful to download the API Documentation, where the jdk tools are all descripted!!
hope it helps,
Thof -
Open Windows Media Player through Java program
I need to open a video and some music in windows media player... but I don't know how....
Can anybody help???I hav implemented windows media player using JSP....i am sending code
However for java program i do not know
<html>
</body>
<!-- begin embedded WindowsMedia file... -->
<table border='0' cellpadding='0' align="left">
<tr><td>
<OBJECT id='mediaPlayer' width="320" height="285"
classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'
codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'
standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>
<param name='fileName' value="c:\abc.wmv">
<param name='animationatStart' value='true'>
<param name='transparentatStart' value='true'>
<param name='autoStart' value="true">
<param name='showControls' value="true">
<param name='loop' value="true">
<EMBED type='application/x-mplayer2'
pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'
id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1'
bgcolor='darkblue' showcontrols="true" showtracker='-1'
showdisplay='0' showstatusbar='-1' videoborder3d='-1' width="320" height="285"
src="c:\abc.wmv" autostart="true" designtimesp='5311' loop="true">
</EMBED>
</OBJECT>
</td></tr>
<!-- ...end embedded WindowsMedia file -->
<!-- begin link to launch external media player... -->
<tr><td align='center'>
<a href="http://servername/path/to/media.file" style='font-size: 85%;' target='_blank'>Launch in external player</a>
<!-- ...end link to launch external media player... -->
</td></tr>
</table>
</body>
</html> -
How to run java programs from a master java program?
Hello,
I have several java programs which run from the command prompt. I am seeking help with code for starting java programs from within a java program. For example, a program called master.java works something like this:
import java.*;
create connection pool
create variables and result sets
start/run slave1.java (var1, var2);
start/run slave2.java (var3, var4, var5);
start/run slave3.java (var1, var4);
end of program master.java
Each of the slave.java programs will run for up to an hour. I do not want the master.java program to pause for each slave program to stop. Instead, the master program will keep running and multiple slave programs will be running simultaneously with the master program. When a slave program starts, it is on its own. Also, if possible, I would like to have each of these slave.java programs open in a new separate command window, so I can observe each slave program running in separate windows.
Any suggestions for code or helpful documentation are greatly appreciated.
Thank you,
LoganThank you all.
At the bottom of master.java I have successfully started a batch file with these lines:
String jcmd = "cmd.exe /c start c:/data/simulations/MsgViewCount2.bat";
Process proc = Runtime.getRuntime().exec(jcmd);
But I still cannot get a java program to start. Here is one variation I have tried:
String [] cmdArray = new String[2];
cmdArray[0] = "java";
cmdArray[1] = "slave1";
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(cmdArray);
This compiles, and no errors occur, but nothing happens.
Regarding this comment:
Why Runtime.exec? Either make the slaves Runnable or
just call their main() methods.
Oh, I see. Sepearate output. :PNone of the slave.java programs have any output.
Thanks again. -
How to execute an external executable in my java program?
hi,
i want to write a java program to execute some external executables.
for example, i had an executable which takes a string as its input parameter, and:
it writes to stdout a string : "[stdout] hello, "+parameter+"!";
it writes to stderr a string : "[stderr] hello, "+parameter+"!".
and it exits with an error code 1.
my java program looks like this:
public class Test {
public static void main(String[] args)
throws Exception {
String inputParameter = "heavyz";
String stdoutOutput = null;
String stderrOutput = null;
int exitCode;
// Do something here to launch the executable,
// providing inputParameter as its input,
// getting its stdout output to String stdoutOutput,
// and its stderr output to String stderrOutput,
// and its exit code to int exitCode.
return;
}anybody can help me to complete the program above?
thanks a lot.
heavy ZHENGcheck out Runtime.getRuntime().exec();
-
Passing argument to shell script from java program
str="/bin/sh -c /root/PWAppSh/StartSH.sh";
p = rt.getRuntime().exec(str);
above is the code snippet of java program for calling the shellscript
when i pass a argument to the shell script from my java program it wont get accepted in shell script as an input
when i do following changes in above code it wont work :---
str="/bin/sh -c /root/PWAppSh/StartSH.sh para1 para2 para3 ";
p = rt.getRuntime().exec(str);
para1,para2 and para3 wont get as argument for the shell script
how this can be done
thanks
reply "ARGENT"Argent.
Read this:
Navigate yourself around pitfalls related to the Runtime.exec() method -
Writing a java program for generating .pdf file with the data of MS-Excel .
Hi all,
My object is write a java program so tht...it'll generate the .pdf file after retriving the data from MS-Excel file.
I used POI HSSF to read the data from MS-Excel and used iText to generate .pdf file:
My Program is:
* Created on Apr 13, 2005
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
package forums;
import java.io.*;
import java.awt.Color;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import com.lowagie.text.Font.*;
import com.lowagie.text.pdf.MultiColumnText;
import com.lowagie.text.Phrase.*;
import net.sf.hibernate.mapping.Array;
import org.apache.poi.hssf.*;
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.hssf.usermodel.*;
import com.lowagie.text.Phrase.*;
import java.util.Iterator;
* Generates a simple 'Hello World' PDF file.
* @author blowagie
public class pdfgenerator {
* Generates a PDF file with the text 'Hello World'
* @param args no arguments needed here
public static void main(String[] args) {
System.out.println("Hello World");
Rectangle pageSize = new Rectangle(916, 1592);
pageSize.setBackgroundColor(new java.awt.Color(0xFF, 0xFF, 0xDE));
// step 1: creation of a document-object
//Document document = new Document(pageSize);
Document document = new Document(pageSize, 132, 164, 108, 108);
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter writer =PdfWriter.getInstance(document,new FileOutputStream("c:\\weeklystatus.pdf"));
writer.setEncryption(PdfWriter.STRENGTH128BITS, "Hello", "World", PdfWriter.AllowCopy | PdfWriter.AllowPrinting);
// step 3: we open the document
document.open();
Paragraph paragraph = new Paragraph("",new Font(Font.TIMES_ROMAN, 13, Font.BOLDITALIC, new Color(0, 0, 255)));
POIFSFileSystem pofilesystem=new POIFSFileSystem(new FileInputStream("D:\\ESM\\plans\\weekly report(31-01..04-02).xls"));
HSSFWorkbook hbook=new HSSFWorkbook(pofilesystem);
HSSFSheet hsheet=hbook.getSheetAt(0);//.createSheet();
Iterator rows = hsheet.rowIterator();
while( rows.hasNext() ) {
Phrase phrase=new Phrase();
HSSFRow row = (HSSFRow) rows.next();
//System.out.println( "Row #" + row.getRowNum());
// Iterate over each cell in the row and print out the cell's content
Iterator cells = row.cellIterator();
while( cells.hasNext() ) {
HSSFCell cell = (HSSFCell) cells.next();
//System.out.println( "Cell #" + cell.getCellNum() );
switch ( cell.getCellType() ) {
case HSSFCell.CELL_TYPE_STRING:
String stringcell=cell.getStringCellValue ()+" ";
writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
phrase.add(stringcell);
// document.add(new Phrase(string));
System.out.print( cell.getStringCellValue () );
break;
case HSSFCell.CELL_TYPE_FORMULA:
String stringdate=cell.getCellFormula()+" ";
writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
phrase.add(stringdate);
System.out.print( cell.getCellFormula() );
break;
case HSSFCell.CELL_TYPE_NUMERIC:
String string=String.valueOf(cell.getNumericCellValue())+" ";
writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
phrase.add(string);
System.out.print( cell.getNumericCellValue() );
break;
default:
//System.out.println( "unsuported sell type" );
break;
document.add(new Paragraph(phrase));
document.add(new Paragraph("\n \n \n"));
// step 4: we add a paragraph to the document
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
// step 5: we close the document
document.close();
My Input from MS-Excel file is:
Planning and Tracking Template for Interns
Name of the Intern N.Kesavulu Reddy
Project Name Enterprise Sales and Marketing
Description Estimated Effort in Hrs Planned/Replanned Actual Actual Effort in Hrs Complexity Priority LOC written new & modified % work completion Status Rework Remarks
S.No Start Date End Date Start Date End Date
1 setup the configuration 31/01/2005 1/2/2005 31/01/2005 1/2/2005
2 Deploying an application through Tapestry, Spring, Hibernate 2/2/2005 2/2/2005 2/2/2005 2/2/2005
3 Gone through Componentization and Cxprice application 3/2/2005 3/2/2005 3/2/2005 3/2/2005
4 Attend the sessions(tapestry,spring, hibernate), QBA 4/2/2005 4/2/2005 4/2/2005 4/2/2005
The o/p I'm gettint in .pdf file is:
Planning and Tracking Template for Interns
N.Kesavulu Reddy Name of the Intern
Enterprise Sales and Marketing Project Name
Remarks Rework Status % work completion LOC written new & modified Priority
Complexity Actual Effort in Hrs Actual Planned/Replanned Estimated Effort in Hrs Description
End Date Start Date End Date Start Date S.No
38354.0 31/01/2005 38354.0 31/01/2005 setup the configuration 1.0
38385.0 38385.0 38385.0 38385.0 Deploying an application through Tapestry, Spring, Hibernate
2.0
38413.0 38413.0 38413.0 38413.0 Gone through Componentization and Cxprice application
3.0
38444.0 38444.0 38444.0 38444.0 Attend the sessions(tapestry,spring, hibernate), QBA 4.0
The issues i'm facing are:
When it is reading a row from MS-Excel it is writing to the .pdf file from last cell to first cell.( 2 cell in 1 place, 1 cell in 2 place like if the row has two cells with data as : Name of the Intern: Kesavulu Reddy then it is writing to the .pdf file as Kesavulu Reddy Name of Intern)
and the second issue is:
It is not recognizing the date format..it is recognizing the date in first row only......
Plz Tell me wht is the solution for this...
Regards
[email protected]Don't double post your question:
http://forum.java.sun.com/thread.jspa?threadID=617605&messageID=3450899#3450899
/Kaj -
Can any Java program be able to auto generate objects?
Like to check if
Java program is be able to auto generate objects?Take example: Point = constructor
Point p =new Point ();
so p is tne name of the object. Er... rite??"p" is the name of a variable. This is a refrence to an object (a instances of a class).
If you are asking what I think you are asking, look at Map. (Collections tutorial)
Please don't take offence, but I recomend taking a read of
Resources for Beginners
Sun's basic Java tutorial
Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
Bruce Eckel's Thinking in Java (Available online.)
Joshua Bloch's Effective Java
Bert Bates and Kathy Sierra's Head First Java. This one has been getting a lot of very positive comments lately. -
Connect Java programs to ABAP generated Web Services
Hi everybody again!
This time I write looking for code examples about connecting my java programs in Netweaver to Abap generated web services.
Could anyone send me any example, please?
Thanks in advance again!
Alberto.Hi,
I'm also looking for code examples about connecting Java programs to ABAP generated Webservices... could you, please, send it to me ?
actually, I need to call bapi from a java Web site.
(as an SOAP request ...)
is it better to <b>generate webser</b>vices from the Bapi then call it,
Or shall i keep the Bapi, and call it from a java webservices based on <b>JCO/RFC</b> calls ...
what's more efficient ?
java webservices + Jco calls to the bapi ?
or direct calls to generated abap webservices ?
thanks
saber -
JSP codes for running a JAVA program
hello...
does anyone know the JSP codes for running a Java program from my web page?? i mean i already have my java program compiled... and i just want this java program to run in the background when I click on a button or a link...
Any idea about this?
plz advice..
aviyes... u r somewhat right... but this runs on Jakarta Tomcat...
i'm using the Apache Http Server together with the ServletExec AS which enable the Apache server to run JSP..
I've created a package where i've put my classes...
WEB-INF/classes/tbd(package name)/my classes
and i've added.. package name.. in my java program..
and then in jsp... i've written..
<%@ page import="tdb.*"%>
<jsp:useBean id="exec" class="tdb.textdb" />
<%exec.convert_data();%>
but when i run the page it says the package does not exist...
can anyone tell where to place the folder WEB-INF so that it can run fine?
thx
avi -
How to read card reader (bar code reader) in simple java program ?
hai all
how to manipulate (read/write) card readers (or bar code reader ) in
a java program ?
should i import any particular package library ?
pls give me any sample code or tutorials or tools, etc (whatever you have) .
i am new to this card reader category
its very urgent
thank you .Nearly all card readers and barcode readers I've ever seen simply stick their input right onto stdin, so you can capture it just as if it had been typed in on a keyboard
-
To generate a wsdl using JAX-WS in JBOSS with java program but without EJB
Hi,
I am using JAX-WS to generate webservices using JBOSS application server by writing a java program.
My sample java program includes :which takes an i/p name as string and displays out put as "Hello name",with the use of annotations.And,also have written web.xml for it.If I start JBOSS without adding project to it,it is starting.BUt If I add project to it the server is not publishing.Its getting like:"publishing JBOSS 4.2.2....:waiting for virtual machine to exit".
I have followed the link:*http://www.javabeat.net/articles/2007/10/creating-webservice-using-jboss-and-eclipse/3*
to do this,where in it was given that by means of auto build process of eclipse IDE war file generates in default jboss folder.But which is not happening,so that,am unable to generate wsdl file..
Can any body help me?
1) why jboss is not publishing after adding project to it?
2) why war file is not generating in the default jboss folder?
Regards....Yeah sure!!
Overall picture: I wish to expose my OSB services to the third parties using OCSG. For that I've created the Communication services corresponding to each OSB service.
Problem: Integration with the OSB.
At the OSB side I've got JMS queues which interacts with other existing systems in my SOA enviornment. But I'm not getting how to get the OCSG application- triggered request messages in that queue? Please help.
Also I've read about the SOA facades for integration with OSB.Which of the two approaches you will suggest?
Maybe you are looking for
-
Configuring the 3750G WLC to use the Internal DHCP Server
I want to use the Internal DHCP Server on a 3750G WLC to hand out IP's to gueat users. I'm having issues getting the DHCP server to hand out addresses for the guest network - any suggestions would be a great help. Configuration Details are attached.
-
How can I change the name that my computer/iTunes assigned to my device?
When I hooked up my new 4s to my desktop, it asked if I wanted to start with a new device. I answered yes and the device was assigned a default name based on the name of the computer (which wasn't originally mine) so now iTunes recognizes the device
-
Upgrade Project: CRM Function Groups
Hi All, The Function groups like "CRM_ISALES_SOLDTO" which was present in SRM 3.0 is replaced in SRM 5.0. I am currently on an upgrade project anr there are several Z FM's which gives a call to the FM's under this function group. Since they are unava
-
Firefox crashes when uploading/downloading files from/to 'desktop folder'
Hello I'm hoping, that you can help me! I'm using Firefox 28.0 on MacBook Pro Mavericks 10.9.2 Firefox crashes/freezes when I try to upload/download files from/to my 'desktop folder'. I't only happens, when I use this folder. Download to 'download fo
-
Hi, Just want to know that I have 2 computers One at office and one at home, Can use the same device on both the computer on i tunes, for sync, backup and buying apps. An urgent reply in this regard will be highly appreciated.