Unable to compile my java program in TextPad or Eclipse
Hello - Finals are next week and I have one last assignment due....and my harddrive crashed last week. I reinstalled everything and set environment variables. When I open my program in TextPad and press ctrl-1 to compile nothing happens. Nothing happens with ctrl-2 (to run) either.
In eclipse, I open the files and try to run the java file with the main method but I get "Selection does not contain a main type" error! I don't know what to do and I am at a standstill and I failed finding helpful information on my own.
Please help!
import java.util.Scanner;
import java.io.*;
import java.util.ArrayList;
public class BookPrinter {
public static void main(String args)
try
FileReader reader = new FileReader("input.txt");
Scanner in = new Scanner(reader);
String inputFile = "";
while(in.hasNext())
inputFile.concat(in.nextLine());
Book b = new Book(inputFile);
System.out.println("The book's size is: " + b.bookSize());
System.out.println("\nThe number of times \"the\" occurs in the book: " + b.count("the"));
System.out.println("\nThe longest word in the book: " + b.longest());
ArrayList<String> longList = b.allLongest();
System.out.println("\nThe words that are all the longest length: ");
while(longList.size() > 0)
for(String e: longList)
System.out.println(e);
catch(FileNotFoundException exception)
System.out.println("Error processing file: " + exception);
}
This:
public static void main(String args)is wrong.
You want this:
public static void main(String[] args)Understand the difference?
Similar Messages
-
Unable to compile the java class in the SQL PLUS
Hi Team,
I am unable to compile the java class in the SQL PLUS in dev1 and dev2. It is giving the following error.
But the same class get Compiled in the Toad(Tool) without any error and working fine. Could someone help me
What to do for this for your reference ,Attaching the java class file.
“ORA-29536: badly formed source: Encountered "<EOF>" at line 1, column 28.
Was expecting one of:
----------------------Here is the Java class Code.....................
create or replace and compile java source named "XXVM_ZipFileUtil_Ela"
as
import java.math.BigDecimal;
import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import oracle.sql.*;
import oracle.jdbc.*;
import java.sql.*;
import java.io.*;
public class XXVM_ZipFileUtil_Ela
public static oracle.sql.BLOB getZipFile(
oracle.sql.CHAR zipFilePathCHAR, oracle.sql.CHAR zipFileNameCHAR,
int fileBufferSize, int zipFileBufferSize,
boolean deleteZipFile, java.sql.Array fileNames, java.sql.Array fileContents, java.sql.Array fileContentsLength)
throws IllegalArgumentException, FileNotFoundException, IOException, java.sql.SQLException
String zipFilePath = (zipFilePathCHAR == null) ? null : zipFilePathCHAR.stringValue();
String zipFileName = (zipFileNameCHAR == null) ? null : zipFileNameCHAR.stringValue();
String zipPathAndFileName = new String(
new String(zipFilePath == null || zipFilePath == "" ? "/tmp/" : zipFilePath) +
new String(zipFileName == null || zipFileName == "" ? System.currentTimeMillis() + ".zip" : zipFileName));
byte[] buffer = new byte[fileBufferSize == 0 ? 100000000 : fileBufferSize];
try
Connection conn = DriverManager.getConnection("jdbc:default:connection:");
oracle.sql.CLOB[] fileContentsCLOB = (oracle.sql.CLOB[])fileContents.getArray();
String[] fileNamesString = (String[])fileNames.getArray();
BigDecimal[] fileContentsLengthNumber = (BigDecimal[])fileContentsLength.getArray();
ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipPathAndFileName));
zipOut.setLevel(Deflater.DEFAULT_COMPRESSION);
for (int i = 0; i < fileNamesString.length; i++) {
System.out.println(i);
zipOut.putNextEntry(new ZipEntry(fileNamesString));
InputStream asciiStream = fileContentsCLOB[i].getAsciiStream(1L);
int asciiReadCount = asciiStream.read(buffer,0,fileContentsLengthNumber[i].intValue());
zipOut.write(buffer, 0, fileContentsLengthNumber[i].intValue());
zipOut.closeEntry();
zipOut.close();
byte zipFileContents[] = new byte[zipFileBufferSize == 0 ? 100000000 : zipFileBufferSize];
FileInputStream zipIn = new FileInputStream(zipPathAndFileName);
int byteCount = zipIn.read(zipFileContents);
zipIn.close();
byte returnFileContents[] = new byte[byteCount];
System.arraycopy(zipFileContents,0,returnFileContents,0,byteCount);
String returnFileContentsString = new String(returnFileContents);
if (deleteZipFile)
boolean deletedFile = (new File(zipPathAndFileName)).delete();
oracle.sql.BLOB returnFileContentsBLOB = null;
returnFileContentsBLOB = BLOB.createTemporary(conn, true, BLOB.DURATION_SESSION);
returnFileContentsBLOB.open(BLOB.MODE_READWRITE);
//OutputStream tempBlobWriter = returnFileContentsBLOB.getBinaryOutputStream();
OutputStream tempBlobWriter = returnFileContentsBLOB.setBinaryStream(1);
tempBlobWriter.write(returnFileContents);
tempBlobWriter.flush();
tempBlobWriter.close();
returnFileContentsBLOB.close();
return returnFileContentsBLOB;
catch (IllegalArgumentException ex) {
ex.printStackTrace();
throw ex;
catch (FileNotFoundException ex) {
ex.printStackTrace();
throw ex;
catch (IOException ex)
ex.printStackTrace();
throw ex;
catch (java.sql.SQLException ex)
ex.printStackTrace();
throw ex;860411 wrote:
Hi Team,
I am unable to compile the java class in the SQL PLUS in dev1 and dev2. It is giving the following error.
But the same class get Compiled in the Toad(Tool) without any error and working fine. Could someone help me
What to do for this for your reference ,Attaching the java class file.
“ORA-29536: badly formed source: Encountered "<EOF>" at line 1, column 28.
Was expecting one of:
I believe the error message is clear and self-explanatory.
----------------------Here is the Java class Code.....................
create or replace and compile java source named "XXVM_ZipFileUtil_Ela"
as
import java.math.BigDecimal;
import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import oracle.sql.*;
import oracle.jdbc.*;
import java.sql.*;
import java.io.*;
public class XXVM_ZipFileUtil_Ela
public static oracle.sql.BLOB getZipFile(
oracle.sql.CHAR zipFilePathCHAR, oracle.sql.CHAR zipFileNameCHAR,
int fileBufferSize, int zipFileBufferSize,
boolean deleteZipFile, java.sql.Array fileNames, java.sql.Array fileContents, java.sql.Array fileContentsLength)
throws IllegalArgumentException, FileNotFoundException, IOException, java.sql.SQLException
String zipFilePath = (zipFilePathCHAR == null) ? null : zipFilePathCHAR.stringValue();
String zipFileName = (zipFileNameCHAR == null) ? null : zipFileNameCHAR.stringValue();
String zipPathAndFileName = new String(
new String(zipFilePath == null || zipFilePath == "" ? "/tmp/" : zipFilePath) +
new String(zipFileName == null || zipFileName == "" ? System.currentTimeMillis() + ".zip" : zipFileName));
byte[] buffer = new byte[fileBufferSize == 0 ? 100000000 : fileBufferSize];
try
Connection conn = DriverManager.getConnection("jdbc:default:connection:");
oracle.sql.CLOB[] fileContentsCLOB = (oracle.sql.CLOB[])fileContents.getArray();
String[] fileNamesString = (String[])fileNames.getArray();
BigDecimal[] fileContentsLengthNumber = (BigDecimal[])fileContentsLength.getArray();
ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipPathAndFileName));
zipOut.setLevel(Deflater.DEFAULT_COMPRESSION);
for (int i = 0; i < fileNamesString.length; i++) {
System.out.println(i);
zipOut.putNextEntry(new ZipEntry(fileNamesString));
InputStream asciiStream = fileContentsCLOB[i].getAsciiStream(1L);
int asciiReadCount = asciiStream.read(buffer,0,fileContentsLengthNumber[i].intValue());
zipOut.write(buffer, 0, fileContentsLengthNumber[i].intValue());
zipOut.closeEntry();
zipOut.close();
byte zipFileContents[] = new byte[zipFileBufferSize == 0 ? 100000000 : zipFileBufferSize];
FileInputStream zipIn = new FileInputStream(zipPathAndFileName);
int byteCount = zipIn.read(zipFileContents);
zipIn.close();
byte returnFileContents[] = new byte[byteCount];
System.arraycopy(zipFileContents,0,returnFileContents,0,byteCount);
String returnFileContentsString = new String(returnFileContents);
if (deleteZipFile)
boolean deletedFile = (new File(zipPathAndFileName)).delete();
oracle.sql.BLOB returnFileContentsBLOB = null;
returnFileContentsBLOB = BLOB.createTemporary(conn, true, BLOB.DURATION_SESSION);
returnFileContentsBLOB.open(BLOB.MODE_READWRITE);
//OutputStream tempBlobWriter = returnFileContentsBLOB.getBinaryOutputStream();
OutputStream tempBlobWriter = returnFileContentsBLOB.setBinaryStream(1);
tempBlobWriter.write(returnFileContents);
tempBlobWriter.flush();
tempBlobWriter.close();
returnFileContentsBLOB.close();
return returnFileContentsBLOB;
catch (IllegalArgumentException ex) {
ex.printStackTrace();
throw ex;
catch (FileNotFoundException ex) {
ex.printStackTrace();
throw ex;
catch (IOException ex)
ex.printStackTrace();
throw ex;
catch (java.sql.SQLException ex)
ex.printStackTrace();
throw ex;
The last two lines above should be
/Srini -
Release 12.0.4 "ego" pages: unable to compile standard .java
Hi All,
I have downloaded all the necessary files and was able to build a local copy of particular set of pages. I even ran those pages in my local setup.
Then to understnad the flow I decompiled few controller CLASS files using JAD. Now I am unable to compile the java files (i have just added few System.out.println's) .
I get errors for the following piece of standard code:
oaapplicationmodule.invokeMethod("getTrainStationsContent", new Serializable[] {
key
, new Class[] {
oracle/jbo/Key ---> Cause of error
I also tried rephrasing "oracle/jbo/Key" as "(Class)oracle.jbo.Key" but no luck.
The error which is displayed is
Error(732,13): field oracle not found in class oracle.apps.ego.item.eu.webui.EgoCreateItemPageLayoutCO
Error(732,20): field jbo not found in class oracle.apps.ego.item.eu.webui.EgoCreateItemPageLayoutCO
Error(732,24): field Key not found in class oracle.apps.ego.item.eu.webui.EgoCreateItemPageLayoutCO
I have checked the import section and it looks fine to me.
Please let me know if any of you have faced this issue before? Am a bit lost here.
Thanks in advance.,
JayI tried with almost every other decompiler available... but nothing resolves this issue. Please let me know if you have anyother alternative.
Thanks again! -
Compiling one java program by another
hi ppl
how to compile a java program by another java program by using javac command.
that is prog A must compile prog B using " javac B.java" commandTry com.sun.tools.javac.Main.
You require JDK_HOME/lib/tools.jar in CLASSPATH. -
Can we get file name which we are compiling in java program
Hi,
I want to know if we can get filename(when compiling) or jarfile(when running) which we are compiling in the program itself.
EX:java -jar myjar.jar
How can I display jar file(i.e myjar.jar) in my program
ex:sop("file which compiled is:"<filename>);can you rephrase the question in english, please!!
-
Unable to compile the Java Files generated by JAXB
Hi,
I have generated the Java Files for a DTD and .xjs file using JAXB. But when i tyr to compile the .java files generated i am getting errors.
My DTD file is addctq.dtd
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT AddCtq (Ctq*)>
<!ELEMENT Ctq (PartNumber ,PartDescription,CtqDescription,CtqType,ProductLine,Supplier,Ppctq,Ctp,Ctc,CtqCode1,CtqCode2,CtqCode3,Commodity,SubCommodity,UnitOfMeasure,Client,SamplingFrequency,Remarks,VariableData)>
<!ELEMENT VariableData (SubGroupSize, Specification,Nominal,Usl,Ual,Lal,Lsl,Zal,RangeVal?,RangeAlarmVal?)>
<!ELEMENT PartNumber (#PCDATA)>
<!ATTLIST PartNumber new CDATA #REQUIRED >
<!ELEMENT PartDescription (#PCDATA)>
<!ELEMENT CtqDescription (#PCDATA)>
<!ELEMENT CtqType (#PCDATA)>
<!ELEMENT ProductLine (#PCDATA)>
<!ELEMENT Supplier (#PCDATA)>
<!ELEMENT Ppctq (#PCDATA)>
<!ELEMENT Ctp (#PCDATA)>
<!ELEMENT Ctc (#PCDATA)>
<!ELEMENT CtqCode1 (#PCDATA)>
<!ELEMENT CtqCode2 (#PCDATA)>
<!ELEMENT CtqCode3 (#PCDATA)>
<!ELEMENT Commodity (#PCDATA)>
<!ELEMENT SubCommodity (#PCDATA)>
<!ELEMENT UnitOfMeasure (#PCDATA)>
<!ELEMENT Client (#PCDATA)>
<!ELEMENT SamplingFrequency (#PCDATA)>
<!ELEMENT Remarks (#PCDATA)>
<!ELEMENT SubGroupSize (#PCDATA)>
<!ELEMENT Specification (#PCDATA)>
<!ELEMENT Nominal (#PCDATA)>
<!ELEMENT Usl (#PCDATA)>
<!ELEMENT Ual (#PCDATA)>
<!ELEMENT Lal (#PCDATA)>
<!ELEMENT Lsl (#PCDATA)>
<!ELEMENT Zal (#PCDATA)>
<!ELEMENT RangeVal (#PCDATA)>
<!ELEMENT RangeAlarmVal (#PCDATA)>
and the .xjs file i created is addctq.xjs
<?xml version="1.0" encoding="UTF-8" ?>
<xml-java-binding-schema version="1.0-ea">
<options package="com.geindustrial.sqms"/>
<element name="AddCtq" type="class" root="true">
<content>
<element-ref name="Ctq"/>
</content>
</element>
<element name="Ctq" type="class">
<content>
<element-ref name="PartNumber"/>
<element-ref name="PartDescription"/>
<element-ref name="CtqDescription"/>
<element-ref name="CtqType"/>
<element-ref name="ProductLine"/>
<element-ref name="Supplier"/>
<element-ref name="Ppctq"/>
<element-ref name="Ctp"/>
<element-ref name="Ctc"/>
<element-ref name="CtqCode1"/>
<element-ref name="CtqCode2"/>
<element-ref name="CtqCode3"/>
<element-ref name="Commodity"/>
<element-ref name="SubCommodity"/>
<element-ref name="UnitOfMeasure"/>
<element-ref name="Client"/>
<element-ref name="SamplingFrequency"/>
<element-ref name="Remarks"/>
<element-ref name="VariableData"/>
</content>
</element>
<element name="VariableData" type="class">
<content>
<element-ref name="SubGroupSize"/>
<element-ref name="Specification"/>
<element-ref name="Nominal"/>
<element-ref name="Usl"/>
<element-ref name="Ual"/>
<element-ref name="Lal"/>
<element-ref name="Lsl"/>
<element-ref name="Zal"/>
</content>
</element>
<element name="PartNumber" type="value">
<attribute name="new"/>
</element>
<element name="PartDescription" type="value">
</element>
<element name="CtqDescription" type="value">
</element>
<element name="CtqType" type="value">
</element>
<element name="ProductLine" type="value">
</element>
<element name="Supplier" type="value">
</element>
<element name="Ppctq" type="value">
</element>
<element name="Ctp" type="value">
</element>
<element name="Ctc" type="value">
</element>
<element name="CtqCode1" type="value">
</element>
<element name="CtqCode2" type="value">
</element>
<element name="CtqCode3" type="value">
</element>
<element name="Commodity" type="value">
</element>
<element name="SubCommodity" type="value">
</element>
<element name="UnitOfMeasure" type="value">
</element>
<element name="Client" type="value">
</element>
<element name="SamplingFrequency" type="value">
</element>
<element name="Remarks" type="value">
</element>
<element name="SubGroupSize" type="value" convert="int">
</element>
<element name="Specification" type="value">
</element>
<element name="Nominal" type="value" convert="float">
</element>
<element name="Usl" type="value" convert="float">
</element>
<element name="Ual" type="value" convert="float">
</element>
<element name="Lal" type="value" convert="float">
</element>
<element name="Lsl" type="value" convert="float">
</element>
<element name="Zal" type="value" convert="float">
</element>
<element name="RangeVal" type="value" convert="float">
</element>
<element name="RangeAlarmVal" type="value" convert="float">
</element>
</xml-java-binding-schema>
When i ran the xjc , it generated 3 .java files
AddCtq.java , Ctq.java and VariableData.java
But i am unable to compile any of the above files...
The Error i am getting is
VariableData.java:710: Undefined variable or class name: AddCtq
return AddCtq.newDispatcher();
^
1 error
If i try to compile AddCtq.java , the Error i am getting is
AddCtq.java:4: Class com.geindustrial.sqms.Ctq not found in import.
import com.geindustrial.sqms.Ctq;
^
AddCtq.java:169: Class com.geindustrial.sqms.Ctq not found.
if (!(ob instanceof Ctq)) {
^
AddCtq.java:170: Class com.geindustrial.sqms.Ctq not found.
throw new InvalidContentObjectException(ob, (Ctq.class));
^
3 errors
And when i try to compile Ctq.java , i am getting the following Error:
Ctq.java:4: Class com.geindustrial.sqms.VariableData not found in import.
import com.geindustrial.sqms.VariableData;
^
1 error
How to solve this problem..Pls advise...
Thanks
SateeshI suspect you are trying to compile the files one by one. You may also be trying to compile them disregarding the package structure.
From your post, I gather these files are in the package: com.geindustrial.sqms
Therefore, if they are not so already, put them under a directory structure:
com/geindustrial/sqms
and then compile with:
javac com/geindustrial/sqms/AddCtq.java com/geindustrial/sqms/Ctq.java com/geindustrial/sqms/VariableData.java
(The above is all on one line.)
HTH,
Manuel Amago. -
Why i am unable to compile this .java
Hi
I get the Error messages
C:\kk>javac BICDownloader.java
BICDownloader.java:61: cannot find symbol
symbol : method openConnection()
location: class java.lang.String
URLConnection urlc = url.openConnection();
^
BICDownloader.java:64: cannot find symbol
symbol : class SSLTunnelSocketFactory
location: class BICDownloader
(new SSLTunnelSocketFactory(proxyHost,proxyPort));
^
Note: BICDownloader.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
When trying to compile
import java.io.IOException;
import java.io.InputStream;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.util.StringTokenizer;
import java.util.Properties;
import java.net.*;
import java.io.*;
import java.security.*;
import javax.net.*;
import javax.net.ssl.*;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
* Created on Mar 2, 2007
* S.W.I.F.T. s.c.r.l.
public class BICDownloader {
private final static String proxyHost = "isln616";
private final static String proxyPort = "9090";
public static void main(String[] args) throws Exception {
int exitcode = 0;
int statusCode;
String url = "https://www2.swift.com/bicdownload/bicdownloader?"
+ "action=getfile&productline=bicdir&product=bicdb&content=delta&format=txt";
HttpClient client = new HttpClient();
GetMethod method = new GetMethod(url);
// Provide custom retry handler if required
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
new DefaultHttpMethodRetryHandler(3, false));
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
//System.setProperty("https.proxyHost",proxyHost);
//System.setProperty("https.proxyPort",proxyPort);
URLConnection urlc = url.openConnection();
if(urlc instanceof com.sun.net.ssl.HttpsURLConnection){
((com.sun.net.ssl.HttpsURLConnection)urlc).setSSLSocketFactory
(new SSLTunnelSocketFactory(proxyHost,proxyPort));
try {
// We strongly recommend obfuscation of password and restricted access to its storage
Properties prop = new Properties();
InputStream fis = (InputStream)new FileInputStream("c:/KK/bicdownload.prop");
prop.load(fis);
// Set Credentials
UsernamePasswordCredentials credentials;
credentials = new UsernamePasswordCredentials(prop.getProperty("username"),
prop.getProperty("password"));
client.getState().setCredentials(new AuthScope("www2.swift.com", 443), credentials);
// Executing the method.
statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
// Handling HTTP error 404 and 500 not covered in this example
// All http error cause in this example exit with status 1.
System.err.println("Method failed: " + method.getStatusLine()+ "\n" +
method.getResponseBodyAsString());
System.out.println(method.getRequestCharSet() + "\n" + method.getRequestHeader("").toString());
exitcode = 1;
else {
//Get the file size from the response body and do something with it
Header[] contlen = method.getResponseHeaders("Content-Length");
if (contlen.length != 0) {
StringTokenizer stone = new StringTokenizer(contlen[0].getValue(), "=");
int size = new Integer(stone.nextToken()).intValue();
// Do something with the file size
System.out.println("File size is: " + size);
// Get the filename from the response body.
InputStream is = method.getResponseBodyAsStream();
Header[] contdisp = method.getResponseHeaders("Content-Disposition");
String filename = null;
StringTokenizer sttwo = new StringTokenizer(contdisp[0].getValue(), "=");
while (sttwo.hasMoreTokens()) filename = sttwo.nextToken();
// Hardcoded disk and directory path are indicative
FileOutputStream fos = new FileOutputStream("c:/kk/" + filename);
byte[] buffer = new byte[4096];
int count = is.read(buffer);
while (count != -1) {
fos.write(buffer, 0, count);
count = is.read(buffer);
fos.flush();
fos.close();
is.close();
} catch (HttpException e) {
exitcode = 2;
System.err.println("Fatal HTTP Error: " + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
exitcode = 3;
System.err.println("Fatal I/O error: " + e.getMessage());
e.printStackTrace();
} finally {
// Release the connection.
method.releaseConnection();
System.exit(exitcode);
System.out.println("Dowload done");
}Look at the Classnames it's complaining about, then look at your import list.
That is the reason, of course.
Edit: The second error has to do with the Classes. The first one, is as pointed out below,
is because how you declared and defined your "url" variable, which should be URL and not String. -
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> -
Unable to compile EJB client program
Hi, I developed a simple client program to an entity bean and I am not able to compile. Following are the few lines picked up from the code: (all my ejb,home and remote classes are under "test" package)
import test.*;
import java.util.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
public class TestClient {
public static void main(String[] args) {
try {
Context initial = new InitialContext();
Object objRef = initial.lookup("MyTestBean");
TestHome home = (TestHome) PortableRemoteObject.narrow(objRef, TestHome.class);
... etc.
I am getting the following compilation error
TestClient.java:13: inconvertible types found : java.lang.Object required: TestHome
TestHome home = (TestHome) PortableRemoteObject.narrow(objRef, TestHome.cl
ass);
The classpath is set to j2ee.jar and the local working directory in which the package "test" resides.
Any help in this matter is greatly appreciated.
Thanks.Greetings,
Hi there,
Did pengjuc's answer help you to solve this problem?
I'd be really interested to know if it did.Unlikely, since the error reported is not with the object reference but with the specified class type. Additionally, this approach is not recommended since it assumes the underlying protocol is always (RMI-)IIOP and not vendor specific - portability is lost.
Thanks
Amanda
Developer Technical Support
Sun Microsystems
http://www.sun.com/developers
Regards,
Tony "Vee Schade" Cook -
Unable to run a java program...
Hi.
I am trying to run a server program that I have implemented, but I'm having some trouble. When I click on the run button, I get the following pop-up message:
Could not find the main method. Program will exit!
On the console it says the following:
java.lang.NoSuchMethodError: main
Exception in thread "main"
Below is the beginning portion of my server class:
public class JamServer
public int groupNum = 0;
int serverPort = 9876;
private ServerSocket ss;
//list of client handling threads
//Vector handlers;
//list of users
public Vector users;
public void main(String args[]) {
try{
ss = new ServerSocket(serverPort);
while(true){
Socket s = ss.accept();
User usr = new User();
usr.setOutput(new DataOutputStream(s.getOutputStream()));
//users.add(usr);
new JamServerThread(this,s,usr);
}catch(IOException e){
System.err.println("Could not listen on port: "+ serverPort);
System.exit(-1);
Does anyone have any idea why it would say it could not find the main method? It's clearly there. Please help!!
Thanks in advance.To further explain, main must be static if you want the JVM to exedute it. Without the static keyword, your main method is simply another instance method which can only be accessed once you have an instance of your class. Static methods can be accessed without instanciating the class. So, the JVM expects to find a method called "main" that is both public and static, takes a String array and returns void.
HTH -
Can't Compile All Java Programs
I've installed java and have put the bin folder in the beginning of the environmental variables path value and separated the other path variables after it with a semicolon and no spaces. I then tried to run a hello world program (javac HelloApp.java) under the correct folder, but instead received a message ('javac' is not recognized as an internal or external command, operable program or batch file). Can anyone help me?
Install jdk
point your path to jdk's --> bin folder
create additional variable name--> classpath
point it to jdk's lib folder
.ok.
Restart
Now --> start -->run-->cmd--> javac [ enter ] if you get +ve output then 99% you have done it
now start -->run-->cmd--> java [ enter ] if you get this also then your done!!!!!!!! -
Unable to compile the java file
Hi,
I am following the step by step process of DOC id : 184339.1 on How to Send an Email With Attachment Via Forms 6i Using ORA_JAVA Package. I downloaded the activation framework and sendmail 1.1.3..When i am compiling the file given the DOC id namely sendmail.java, I get the following error
Exception in thread "main" java.lang.NoclassDefFoundError: sendmail/java
Could anyone help me out ..
Below is the cut and paste of the code which is used to compile..
Thanks
Kal
import java.util.*; import java.io.*; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; public class SendMail { // Sender, Recipient, CCRecipient, and BccRecipient are comma- // separated lists of addresses; // Body can span multiple CR/LF-separated lines; // Attachments is a ///-separated list of file names; public static int Send(String SMTPServer, String Sender, String Recipient, String CcRecipient, String BccRecipient, String Subject, String Body, String ErrorMessage[], String Attachments) { // Error status; int ErrorStatus = 0; // create some properties and get the default Session; Properties props = System.getProperties(); props.put("mail.smtp.host", SMTPServer); Session session = Session.getDefaultInstance(props, null); try { // create a message; MimeMessage msg = new MimeMessage(session); // extracts the senders and adds them to the message; // Sender is a comma-separated list of e-mail addresses as // per RFC822; { InternetAddress[] TheAddresses = InternetAddress.parse(Sender); msg.addFrom(TheAddresses); } // extract the recipients and assign them to the message; // Recipient is a comma-separated list of e-mail addresses // as per RFC822; { InternetAddress[] TheAddresses = InternetAddress.parse(Recipient); msg.addRecipients(Message.RecipientType.TO, TheAddresses); } // extract the Cc-recipients and assign them to the // message; // CcRecipient is a comma-separated list of e-mail // addresses as per RFC822; if (null != CcRecipient) { InternetAddress[] TheAddresses = InternetAddress.parse(CcRecipient); msg.addRecipients(Message.RecipientType.CC, TheAddresses); } // extract the Bcc-recipients and assign them to the // message; // BccRecipient is a comma-separated list of e-mail // addresses as per RFC822; if (null != BccRecipient) { InternetAddress[] TheAddresses = InternetAddress.parse(BccRecipient); msg.addRecipients(Message.RecipientType.BCC, TheAddresses); } // subject field; msg.setSubject(Subject); // create the Multipart to be added the parts to; Multipart mp = new MimeMultipart(); // create and fill the first message part; { MimeBodyPart mbp = new MimeBodyPart(); mbp.setText(Body); // attach the part to the multipart; mp.addBodyPart(mbp); } // attach the files to the message; if (null != Attachments) { int StartIndex = 0, PosIndex = 0; while (-1 != (PosIndex = Attachments.indexOf("///", StartIndex))) { // create and fill other message parts; MimeBodyPart mbp = new MimeBodyPart(); FileDataSource fds = new FileDataSource(Attachments.substring(StartIndex, PosIndex)); mbp.setDataHandler(new DataHandler(fds)); mbp.setFileName(fds.getName()); mp.addBodyPart(mbp); PosIndex += 3; StartIndex = PosIndex; } // last, or only, attachment file; if (StartIndex < Attachments.length()) { MimeBodyPart mbp = new MimeBodyPart(); FileDataSource fds = new FileDataSource(Attachments.substring(StartIndex)); mbp.setDataHandler(new DataHandler(fds)); mbp.setFileName(fds.getName()); mp.addBodyPart(mbp); } } // add the Multipart to the message; msg.setContent(mp); // set the Date: header; msg.setSentDate(new Date()); // send the message; Transport.send(msg); } catch (MessagingException MsgException) { ErrorMessage[0] = MsgException.toString(); Exception TheException = null; if ((TheException = MsgException.getNextException()) != null) ErrorMessage[0] = ErrorMessage[0] + "\n" + TheException.toString(); ErrorStatus = 1; } return ErrorStatus; } }Most common cause of the problem: JAVA_HOME environment variable not set, or set incorrectly.
It should point to your java directory: ie C:\java1_4\ NOT C:\java1_4\bin
Another possible cause is spaces in the path names where you have installed applications.
Check out this page: http://www.coreservlets.com/Apache-Tomcat-Tutorial/ for a tutorial on installing tomcat.
If you can't sort it out on your own, we need more info:
Where have you installed Java?
Where have installed Tomcat?
What is the value of JAVA_HOME environment variable?
Good luck,
evnafets -
Unable to compile "SerialDemo.java", many "cannot find symbols" errors
I have all the correct files in their respective directory.
comm.jar in jre\lib\bin,
javax.comm.properties in jre\lib
win32com.dll in jre\bin
I extracted all the whole of SerialDemo into one folder and started compiling from there. But it doesn't work. I keep getting many "cannot find symbol" errors. They are usually referred to by:
SerialParameters
SerialConnection
AlertDialog
SerialConnectionException
SerialDemo.java is not edited and was compiled directly. All of my files are in one folder (AlertDialog.java compiles fine and is in the same folder, etc)
I was wondering what might be the cause of it. I'm currently using a Windows XP Service Pack 2, IBM P3 Laptop. I was reading "http://forum.java.sun.com/thread.jspa?threadID=674514&messageID=3941560"
And I found out it works fine on Win2k OS. Why is this so? I'm getting the exact same error as he stated on his last post and I tried looking for a solution and decided to turn to you guys. I'd really appreciate some help, if any. Thanks in advance.I followed the PlatformSpecific. I realised that I
added one for JRE when it wasn't required. The
problem was solved.
Thank you so much, the both of you. My stupid mistake
caused quite a bit of havoc. I apologise.No need to apologise; The confusing part is that when you download
a jre, that's just what your get: a jre, but when you download the jdk
you not just get the jdk and the jre but you get a second jre with them,
stored under the jdk directory.
To the programmer that second jre is useless, it is used internally by
the jdk tools.
kind regards,
Jos -
Unable to print through Java program
Hi all,
I have downloaded a sample java code to print text. When i try to print on solaris, it displays some postscript characters like:
%! PS-Adobe-3.0%%BeginProlog/imStr 0 def /heximageSrc....
But i am able to print the same information through lp command correctly.
I am using EPSON - LP8200. As per my knowledge, this printer doesn't support postscript printing
The sample java code works perfectly on Win2k connected to the same printer.
Please help me out. I am stuckup in this problem for quite a few days
Below is the code that i am using
// This example is from the book Java AWT Reference by John Zukowski.
// Written by John Zukowski. Copyright (c) 1997 O'Reilly & Associates.
// You may study, use, modify, and distribute this example for any purpose.
// This example is provided WITHOUT WARRANTY either expressed or
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.awt.print.*;
public class TestPrintEx extends Frame implements Printable {
TextArea textArea;
Label statusInfo;
Button loadButton, printButton, closeButton;
Properties p = new Properties();
Vector pages = new Vector();
static boolean bFirstTime = false;
public TestPrintEx() {
super ("File Loader");
add (statusInfo = new Label(), "North");
Panel p = new Panel ();
p.add (loadButton = new Button ("Load"));
loadButton.addActionListener( new LoadFileCommand() );
p.add (printButton = new Button ("Print"));
printButton.addActionListener( new PrintCommand() );
p.add (closeButton = new Button ("Close"));
closeButton.addActionListener( new CloseCommand() );
add (p, "South");
add (textArea = new TextArea (10, 40), "Center");
pack();
public static void main (String args[]) {
TestPrintEx f = new TestPrintEx();
f.show();
// Bail Out
class CloseCommand implements ActionListener {
public void actionPerformed (ActionEvent e) {
System.exit (0);
// Load a file into the text area.
class LoadFileCommand implements ActionListener {
public void actionPerformed (ActionEvent e) {
int state;
String msg;
FileDialog file = new FileDialog (TestPrintEx.this, "Load File", FileDialog.LOAD);
file.setFile ("*.java"); // Set initial filename filter
file.show(); // Blocks
String curFile;
if ((curFile = file.getFile()) != null) {
String filename = file.getDirectory() + curFile;
char[] data;
setCursor (Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
File f = new File (filename);
try {
FileReader fin = new FileReader (f);
int filesize = (int)f.length();
data = new char[filesize];
fin.read (data, 0, filesize);
} catch (FileNotFoundException exc) {
String errorString = "File Not Found: " + filename;
data = errorString.toCharArray ();
} catch (IOException exc) {
String errorString = "IOException: " + filename;
data = errorString.toCharArray ();
statusInfo.setText ("Load: " + filename);
textArea.setText (new String (data));
System.out.println("#### " + new String(data));
setCursor (Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
// Print a file into the text area.
class PrintCommand implements ActionListener {
public void actionPerformed (ActionEvent e) {
PrinterJob pjob = PrinterJob.getPrinterJob();
TestPrintEx.bFirstTime = true;
pjob.setPrintable(TestPrintEx.this);
try{
//pjob.print();
pjob.printDialog();
catch(PrinterException pe)
pe.printStackTrace();
pjob.printDialog();
class Page
Vector lines;
Page()
lines = new Vector();
void addLine(String s)
lines.addElement(s);
Enumeration getLines()
return lines.elements();
void print(Graphics pg, PageFormat pf)
System.out.println("Printing page now");
// Note: String is immutable so won't change while printing.
if (!(pg instanceof PrinterGraphics)) {
throw new IllegalArgumentException ("Graphics context not PrintGraphics");
//--- Create the Graphics2D object
Graphics2D g2d = (Graphics2D) pg;
//--- Translate the origin to 0,0 for the top left corner
g2d.translate (pf.getImageableX (), pf.getImageableY ());
//--- Set the default drawing color to black
g2d.setPaint (Color.black);
//--- Draw a border around the page
Rectangle border = new Rectangle(0,
0,
(int)(pf.getImageableWidth()),
(int)(pf.getImageableHeight()));
g2d.draw (border);
int pageHeight = (int)pf.getImageableHeight();
//Font helv = new Font("Helvetica", Font.PLAIN, 12);
Font helv = new Font(null, Font.PLAIN, 12);
//have to set the font to get any output
g2d.setFont (helv);
FontMetrics fm = g2d.getFontMetrics(helv);
int fontHeight = fm.getHeight();
int fontDescent = fm.getDescent();
int curHeight = (int)(pf.getImageableY() + 72);
int size = lines.size();
for(int i = 0; i < size; i++)
curHeight += fontHeight;
if (g2d != null) {
g2d.drawString ((String)lines.elementAt(i),
(int)(pf.getImageableX () + 72), curHeight - fontDescent);
} else {
System.out.println ("pg null");
g2d.dispose();
public int print(Graphics pg, PageFormat pf, int index)
if(bFirstTime)
System.out.println("First time - paginating");
paginate(pg, pf);
bFirstTime = false;
System.out.println("No of pages = " + pages.size());
if(!isValidIndex(index))
return Printable.NO_SUCH_PAGE;
((Page)pages.elementAt(index)).print(pg, pf);
return Printable.PAGE_EXISTS;
boolean isValidIndex(int index)
if(index >= 0 && index < pages.size())
return true;
return false;
void paginate(Graphics pg, PageFormat pf)
pages.clear();
// Note: String is immutable so won't change while printing.
if (!(pg instanceof PrinterGraphics)) {
throw new IllegalArgumentException ("Graphics context not PrintGraphics");
//--- Create the Graphics2D object
Graphics2D g2d = (Graphics2D) pg;
//--- Translate the origin to 0,0 for the top left corner
g2d.translate (pf.getImageableX (), pf.getImageableY ());
String s = textArea.getText();
StringReader sr = new StringReader (s);
LineNumberReader lnr = new LineNumberReader (sr);
String nextLine;
int pageHeight = (int)pf.getImageableHeight();
Font helv = new Font(null, Font.PLAIN, 12);
//have to set the font to get any output
g2d.setFont (helv);
FontMetrics fm = g2d.getFontMetrics(helv);
int fontHeight = fm.getHeight();
int fontDescent = fm.getDescent();
int curHeight = (int)(pf.getImageableY() + 72);
Page page = new Page();
pages.addElement(page);
try {
do {
nextLine = lnr.readLine();
if (nextLine != null) {
if ((curHeight + fontHeight) > pageHeight - 72) {
page = new Page();
pages.addElement(page);
curHeight = 0;
curHeight += fontHeight;
if (g2d != null) {
page.addLine(nextLine);
} else {
System.out.println ("pg null");
} while (nextLine != null);
} catch (EOFException eof) {
// Fine, ignore
} catch (Throwable t) { // Anything else
t.printStackTrace();
ThanksDid you ever find a resolution to this problem.
I am having the same exact problem? -
Does anybody here know how I can compile my java programs?
I downloaded j2se 1.4.0 and j2se 1.4.1 and for some reason I can't the javac command in the bin directory. There is a command called javaw but I don't know what it does. can anyone help me?
Please Check whether JRE is installed with the SDK set up. If you are running Windows OS then edit the "AUTOEXEC.BAT" file so that all the commands will run.
Do this ---
C:\>edit autoexec.bat
and at the end of the file add ---
SET PATH=%PATH%;drive-name\java-installation folder.
ex
SET PATH=%PATH%;C:\JDK1.4\BIN;
save and exit.
It should work.
javaw is used to run executable jar files.
Maybe you are looking for
-
CentOS 5.4 64 bit srss 4.2 troubles
Hi have 3 sun ray 170 thin clients that used to work on an older sunfire v250, but now we have upgraded to a new IBM 3500 series running CentOS 5.4 64 bit. We are trying to get the thin 170s to work with the new 4.2 version of sun ray software. We ha
-
Unable to open CR2 photos in Photoshop CS3.
I am unable to open some very important wedding CR2 files in Photoshop CS3. What specific updates do I need to fix this? The raw photoUns were shot on a Canon 70D. The photos were shot in low lighting so I shot in a large format that I don't typicall
-
LMS 4.0.1 Create CPU Utilization Quick Report
LMS 4.0.1 Create CPU Utilization Quick Report not work,then not any error!
-
Regarding Replacement of Iphone5
Hello sir , I am facing alot of problem with my Iphone 5 (Touch is not working Properly , Battery back up is not good , Network Problem , Sometimes it get hang ) , This is My first Apple Product ,It was like dream for me and I was very much excited
-
Identifying Multiple printers with unique name?
I support an office staff of 40 users that share 15 Officejet 100 L411a printers. When users connect a printer by USB, the computer will create a new printer with the default name "HP Officejet 100 Mobile L411" printer if that printer hasn't connecte