LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-26-2011, 01:51 AM   #1
dhanapal2005
LQ Newbie
 
Registered: Feb 2011
Posts: 4

Rep: Reputation: 0
Error in java coding....pls sir....


Sir,
I have one program doubt and i compile it will produce 26 errors.... pls help me

PROGRAM:

package org.xmlBlaster.authentication.plugins.htpasswd;
import org.xml.sax.Attributes;
import org.xmlBlaster.util.XmlBlasterException;
import org.xmlBlaster.util.SaxHandlerBase;
import org.xmlBlaster.util.Global;
import org.xmlBlaster.util.def.Constants;
import org.xmlBlaster.authentication.plugins.I_SecurityQos;
import org.jutils.text.StringHelper;
/**
* Parse the security informations loginName and password
* from the login qos xml string:
* <pre>
* &lt;securityService type="htpasswd" version="1.0">
* &lt;user>tim&lt;/user>
* &lt;passwd>tim&lt;/passwd>
* &lt;/securityService>
* </pre>
*
* @author <a href="mailto:cyrille@ktaland.com">Cyrille Giquello</a> 16/11/01 09:06
*/
public final class SecurityQos extends SaxHandlerBase implements I_SecurityQos
{
private static String ME = "SecurityQos-htpasswd";

// helper flags for SAX parsing
private transient boolean inSecurityService = false;
private transient boolean inUser = false;
private transient boolean inPasswd = false;
private String type = "htpasswd";
private String version = "1.0";
private String user = null;
private String passwd = null;
public SecurityQos(Global glob)
{
super(glob);
}

public SecurityQos(Global glob, String xmlQos_literal) throws XmlBlasterException
{
super(glob);
parse(xmlQos_literal);
}
public void parse(String xmlQos_literal) throws XmlBlasterException
{
// Strip CDATA tags that we are able to parse it:
xmlQos_literal = StringHelper.replaceAll(xmlQos_literal, "<![CDATA[", "");
xmlQos_literal = StringHelper.replaceAll(xmlQos_literal, "]]>", "");
init(xmlQos_literal);
}
public SecurityQos(String loginName, String password)
{
this.user = loginName;
this.passwd = password;
}
public String getPluginVersion() {
return version;
}
public String getPluginType() {
return type;
}
public void setUserId(String userId)
{
this.user = userId;
}
public String getUserId()
{
return user;
}
/**
* @param cred The password
*/
public void setCredential(String cred)
{
this.passwd = cred;
}
/**
* @return null (no password is delivered)
*/
String getCredential()
{
return this.passwd;
}
/**
* Start element, event from SAX parser.
* <p />
* @param name Tag name
* @param attrs the attributes of the tag
*/
public void startElement(String uri, String localName, String name, Attributes attrs)
{
if (name.equalsIgnoreCase("securityService")) {
inSecurityService = true;
if (attrs != null) {
int len = attrs.getLength();
int ii=0;
for (ii = 0; ii < len; ii++) {
if (attrs.getQName(ii).equalsIgnoreCase("type")) {
type = attrs.getValue(ii).trim();
}
else if (attrs.getQName(ii).equalsIgnoreCase("version")) {
version = attrs.getValue(ii).trim();
}
}
}
character.setLength(0);
return;
}
if (name.equalsIgnoreCase("user")) {
inUser = true;
character.setLength(0);
return;
}
if (name.equalsIgnoreCase("passwd")) {
inPasswd = true;
character.setLength(0);
return;
}
}

/**
* End element, event from SAX parser.
* <p />
* @param name Tag name
*/
public void endElement(String uri, String localName, String name)
{
if (name.equalsIgnoreCase("user")) {
inUser = false;
user = character.toString().trim();
character.setLength(0);
return;
}
if (name.equalsIgnoreCase("passwd")) {
inPasswd = false;
passwd = character.toString().trim();
character.setLength(0);
return;
}
if (name.equalsIgnoreCase("securityService")) {
inSecurityService = false;
character.setLength(0);
return;
}
}
public final String toXml()
{
return toXml((String)null);
}
/**
* Dump state of this object into a XML ASCII string.
* <br>
* @param extraOffset indenting of tags for nice output
* @return The xml representation
*/
public final String toXml(String extraOffset)
{
StringBuffer sb = new StringBuffer(250);
if (extraOffset == null) extraOffset = "";
String offset = Constants.OFFSET + extraOffset;
sb.append(offset).append("<securityService type=\"").append(getPluginType()).append("\" version=\"").append(getPluginVersion()).append("\"><![CDATA[");
sb.append(offset).append(" <user>").append(user).append("</user>");
sb.append(offset).append(" <passwd>").append(passwd).append("</passwd>");
sb.append(offset).append("]]></securityService>");
return sb.toString();
}
/** For testing: java org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos */
public static void main(String[] args)
{
try {
Global glob = new Global(args);
String xml =
"<securityService type=\"htpasswd\" version=\"1.0\">\n" +
" <![CDATA[\n" +
" <passwd>theUsersPwd</passwd>\n" +
" <user>aUser</user>\n" +
" ]]>\n" +
"</securityService>";
System.out.println("Original:\n" + xml);
SecurityQos qos = new SecurityQos(glob, xml);
System.out.println("Result:\n" + qos.toXml());
qos.setUserId("AnotherUser");
qos.setCredential("AnotherPassword");
System.out.println(qos.toXml());
}
catch(Throwable e) {
System.err.println("TestFailed: " + e.toString());
}
}
}

ERROR:

C:\PROGRA~1\Java\JDK16~1.0_0\bin>edit SecurityQos.java

C:\PROGRA~1\Java\JDK16~1.0_0\bin>javac SecurityQos.java
SecurityQos.java:3: package org.xmlBlaster.util does not exist
import org.xmlBlaster.util.XmlBlasterException;
^
SecurityQos.java:4: package org.xmlBlaster.util does not exist
import org.xmlBlaster.util.SaxHandlerBase;
^
SecurityQos.java:5: package org.xmlBlaster.util does not exist
import org.xmlBlaster.util.Global;
^
SecurityQos.java:6: package org.xmlBlaster.util.def does not exist
import org.xmlBlaster.util.def.Constants;
^
SecurityQos.java:7: cannot find symbol
symbol : class I_SecurityQos
location: package org.xmlBlaster.authentication.plugins
import org.xmlBlaster.authentication.plugins.I_SecurityQos;
^
SecurityQos.java:8: package org.jutils.text does not exist
import org.jutils.text.StringHelper;
^
SecurityQos.java:21: cannot find symbol
symbol: class SaxHandlerBase
public final class SecurityQos extends SaxHandlerBase implements I_SecurityQos
^
SecurityQos.java:21: cannot find symbol
symbol: class I_SecurityQos
public final class SecurityQos extends SaxHandlerBase implements I_SecurityQos
^
SecurityQos.java:33: cannot find symbol
symbol : class Global
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
public SecurityQos(Global glob)
^
SecurityQos.java:37: cannot find symbol
symbol : class Global
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
public SecurityQos(Global glob, String xmlQos_literal) throws XmlBlasterExcept
ion
^
SecurityQos.java:37: cannot find symbol
symbol : class XmlBlasterException
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
public SecurityQos(Global glob, String xmlQos_literal) throws XmlBlasterExcept
ion
^
SecurityQos.java:42: cannot find symbol
symbol : class XmlBlasterException
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
public void parse(String xmlQos_literal) throws XmlBlasterException
^
SecurityQos.java:45: cannot find symbol
symbol : variable StringHelper
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
xmlQos_literal = StringHelper.replaceAll(xmlQos_literal, "<![CDATA[", "");

^
SecurityQos.java:46: cannot find symbol
symbol : variable StringHelper
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
xmlQos_literal = StringHelper.replaceAll(xmlQos_literal, "]]>", "");
^
SecurityQos.java:47: cannot find symbol
symbol : method init(java.lang.String)
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
init(xmlQos_literal);
^
SecurityQos.java:105: cannot find symbol
symbol : variable character
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
character.setLength(0);
^
SecurityQos.java:110: cannot find symbol
symbol : variable character
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
character.setLength(0);
^
SecurityQos.java:115: cannot find symbol
symbol : variable character
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
character.setLength(0);
^
SecurityQos.java:130: cannot find symbol
symbol : variable character
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
user = character.toString().trim();
^
SecurityQos.java:131: cannot find symbol
symbol : variable character
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
character.setLength(0);
^
SecurityQos.java:136: cannot find symbol
symbol : variable character
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
passwd = character.toString().trim();
^
SecurityQos.java:137: cannot find symbol
symbol : variable character
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
character.setLength(0);
^
SecurityQos.java:142: cannot find symbol
symbol : variable character
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
character.setLength(0);
^
SecurityQos.java:161: cannot find symbol
symbol : variable Constants
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
String offset = Constants.OFFSET + extraOffset;
^
SecurityQos.java:172: cannot find symbol
symbol : class Global
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
Global glob = new Global(args);
^
SecurityQos.java:172: cannot find symbol
symbol : class Global
location: class org.xmlBlaster.authentication.plugins.htpasswd.SecurityQos
Global glob = new Global(args);
^
26 errors
 
Old 02-26-2011, 11:43 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,617

Rep: Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963
Quote:
Originally Posted by dhanapal2005 View Post
Sir,
I have one program doubt and i compile it will produce 26 errors.... pls help me

SecurityQos.java:4: package org.xmlBlaster.util does not exist
import org.xmlBlaster.util.SaxHandlerBase;
There are not just "sirs" on this forum, and spell out your words

And did you read the error message??
Quote:
Originally Posted by dhanapa
Code:
SecurityQos.java:4: package org.xmlBlaster.util does not exist
import org.xmlBlaster.util.SaxHandlerBase;
Your code can't find the package you're specifying. Either put it in the correct search path, or specify the correct location in the include.
 
Old 02-27-2011, 12:01 AM   #3
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

1. follow these instructions to build XmlBlaster:
http://www.xmlblaster.org/xmlBlaster/INSTALL

2. If you want to compile your program to use XmlBlaster classes, then include the .jar in your classpath
EXAMPLE:
javac -cp XmlBlaster.jar MyClass.java
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Sir Bill and Sir Tim: A Tale of Two Knights LXer Syndicated Linux News 0 07-02-2008 12:00 AM
LXer: C++ Generic Coding vs. Java Frameworks LXer Syndicated Linux News 0 10-09-2006 04:03 AM
Coding java in a php script mrobertson Programming 44 06-27-2005 01:16 PM
Error in coding a java server. mrobertson Programming 3 06-02-2005 01:37 PM
What is the main used program for coding Java? Tyir Programming 2 10-20-2003 08:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration