Importing self created classes

Hi I'm making a simple .jsp page which queries a database and then returns results in another html page. I am using a few of my own self defined classes to make the page but I don't know how to import them... there aren't any problems with my classes because they work on a servlet I am using.
I think there might also be some problems with my syntax... any help is appreciated.
the root to my classes is:
C:\Prg\Apache\Tomcat5.5.17\webapps\a4020_28503_BMF
and here is my BooksFinder.jsp
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
  "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<%@
     page language = "java"
     import = "java.util.*, webapps.a4020_28503_BMF.WEB-INF.classes.*"
     session = "true"
%>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
     <title>Book List</title>
</head>
<body>
     <%
          String title = request.getParameter("title");
          BookAccessor accessor = new BookAccessor();
          BookBean currentBook;
          ArrayList myBooks = new ArrayList();
          myList = accessor.selectBooksByTitleLike(title);
          List titles = myList;
          Iterator iterator = titles.iterator();
          while (iterator.hasNext() )
               currentBook = (BookBean) iterator.next();
               %>
               < a href = "displayBook?ID=<%= currentBook.getBookID() %>" >
                    <% =      currentBook.getTitle() + ", " +
                    currentBook.getPublisher() + "," +
                    currentBook.getPrice() + "e" %>
               </a><br />
     <%
     %>
</body>
</html>-----------------------------------
The HTML page which calls BooksFinder.jsp is bookSearch2.html:
<html xmlns = "http://www.w3.org/1999/xhtml">
     <head>
                <title>book database</title>
          <script language = "JavaScript">
            function submitToServer (btnAction)
                   update.regAction.value = btnAction ;
                   update.submit() ;
          </script>        
     </head>
     <body>
          <form name="update" method ="get" action ="BooksFinder.jsp" target="_blank">
               <p>
                       <label>Book Title:
                              <input name = "title" type = "text" size = "25" maxlength = "30" />
                    </label>
               </p>
               <p>
                    <input type = "submit" name ="btnSelect" id ="btnSelect"
                    value = "SELECT" onClick="submitToServer('select');"/>
               </p>
               <p>
                    <input type="hidden" value="" name="regAction" id="regAction"/>
               </p>
          </form>
     </body>
</html>----------------------------------------------------
thanks I have been trying hard to figure out how to do this and don't know what to fix :(
Message was edited by:
kidMetropolis

First of all the classes you write have to be in a package. That's a Java rule, you can't import a class that isn't in a package. So suppose your class is named BookAccessor and you put it in the org.whatever package. Then your WEB-INF/classes directory has to have a subdirectory named "org", and that has to have a subdirectory named "whatever", and in there you put your BookAccessor.class file. And your JSP import would look like this:<%@
     page language = "java"
     import = "java.util.*, org.whatever.*"
     session = "true"
%>

Similar Messages

  • Problem with importing and creating self signed SSL certificate

    Mac Pro, 10.7.2 Server.  Attempting to import or create a self signed certificate for use as ichat.domain.com to encrypt iChat service.  Server is acutally called server.domain.com but has an alias of ichat.domain.com.  I understand that this is probably not best practice but I would like to keep things this way since we have one server, run multiple services on it, but want to continue to connect to each service at SERVICE.domain.com.  We have been using this type of mismatched certificate with success since 10.4 or so.
    I am working through setup of 10.7 Server to replace our 10.6 server. 
    Tried upgrade of 10.6 to 10.7 installation.  The installation made a mess of some services and our Open Directory, but did move the certificate over and allowed iChat service to function properly.
    Clean install and setup of 10.7 Server.  Exported self signed certificate, private key, and encryption password from 10.6 Server and functioning 10.7 upgraded Server.
    On import or manual creation of certificate get the following error:
    Error
    Check your server's logs for more information.  The error (code 5001) was: Expected SecKeychainItemImport to return a SecIdentityRef, but it did not
    Log shows:
    Dec 29 17:56:55 server servermgrd[498]: -[CertsRequestHandler(HelperAdditions) importP12Data:passphrase:error:]: importedItems = (
                  "<SecCertificate 0x7fcf6ed43c00 [0x7fff78d96f40]>"
    I have tried importing and manually creating other certificates with a variety of names with success.  I assume that there is something buried somewhere that is causing this particular one to be a problem.  Other than manually removing any remnants of the certificate from /etc/certficates I do not have any ideas what to try.  I am essentially ready to move this server to 10.7 except for this problem and would like to avoid a reinstall.
    Suggestions?
    -Erich

    Take a look here.
    https://bbs.archlinux.org/viewtopic.php?id=146649
    Maybe it's a problem with your network.

  • Problem with import statement for user created classe

    I recently downloaded J2sdk1.4.0_03 before that I had jdk1.3 and never had this problem.All the files other than named package I import for my
    application does not compile.But when I commented that out it work just fine.
    any help is appreciated

    thanks
    It makes sense not to import non-packaged class.
    My other problem is with JDBC ODBC.I have a Dell system with Windows XP.
    I registered my User Data Source to ODBC with MS Text driver(.txt , csv).When the code reaches at the .executeUpdate(CREAT TABLE CUSTOMERS)
    it throws an exception
    sQLException 3:java.sql.SQLException: [Microsoft][ODBC Text Driver] Cannot modify the design of table 'CUSTOMERS'. It is in a read-only database.
    Do I really need to change the attribues or some thing else.
    How can I chane the attributes of the database.Never had problem with windows 98.

  • Error during BCC base data import:  Unable to create class DeploymentServer

    Unable to create class atg.deployment.server.DeploymentServer for configuration /atg/epub/DeploymentServer java.lang.NoClassDefFoundError
    Hello~~~. Can anyone point me into the right direction
    I had checked my class path it got atg.deployment.server.DeploymentServer.
    and the 'legacy' /atg/epub/DeploymentServe looks like (which is doing nothing...really)
    #/atg/epub/DeploymentServer/
    #/atg/epub/DeploymentServer property allowMissingNonEssentialAgents is set to true. By default, this property is set to false. If set to false, unessential agents are treated like essential agents and must be online and functional during deployment.
    #All agents that are flagged as essential are online and functional.
    #allowMissingNonEssentialAgents     false
    ----------stack trace error ---------------
    [exec] **** info     Wed Mar 07 10:20:01 EST 2012     1331076001656     /DPSLicense     atg.service.ServiceResources->dynamoPrintMaxSessions : Only 20 concurrent sessions can be managed with this license
    [exec] **** info     Wed Mar 07 10:20:01 EST 2012     1331076001656     /DPSLicense     atg.service.ServiceResources->dynamoPrintMaxDynamoServers : Only 3 Dynamo server(s) can be used concurrently with this license
    [exec] **** info     Wed Mar 07 10:20:01 EST 2012     1331076001656     /DPSLicense     DPS is licensed to Hutchison 3G Australia Pty Limited - Development
    [exec] **** info     Wed Mar 07 10:20:01 EST 2012     1331076001656     /DPSLicense     atg.service.ServiceResources->unlimitedLicenseMsg : This product is licensed for an unlimited number of CPUs.
    [exec] **** info     Wed Mar 07 10:20:03 EST 2012     1331076003062     /atg/epub/version/VersionManagerRepository     SQL Repository startup complete
    [exec] **** info     Wed Mar 07 10:20:03 EST 2012     1331076003203     /atg/dynamo/server/SQLRepositoryEventServer     Service /atg/dynamo/server/SQLRepositoryEventServer listening at http://cgi-hxc15q12:3040/
    [exec] **** info     Wed Mar 07 10:20:03 EST 2012     1331076003265     /atg/epub/process/ProcessData-ver     SQL Repository startup complete
    [exec] **** info     Wed Mar 07 10:20:03 EST 2012     1331076003281     /atg/epub/process/ProcessDataRepository     SQL Repository startup complete
    [exec] **** info     Wed Mar 07 10:20:03 EST 2012     1331076003390     /atg/epub/file/PublishingFiles-ver     SQL Repository startup complete
    [exec] **** info     Wed Mar 07 10:20:03 EST 2012     1331076003421     /atg/epub/file/PublishingFileRepository     SQL Repository startup complete
    [exec] **** info     Wed Mar 07 10:20:03 EST 2012     1331076003781     /atg/userprofiling/InternalProfileRepository     SQL Repository startup complete
    [exec] **** info     Wed Mar 07 10:20:03 EST 2012     1331076003890     /atg/dynamo/security/AdminSqlRepository     SQL Repository startup complete
    [exec] **** info     Wed Mar 07 10:20:03 EST 2012     1331076003890     /atg/dynamo/security/AdminAccountInitializer     Initializing account database /atg/dynamo/security/AdminAccountManager from /atg/dynamo/security/SimpleXmlUserAuthority
    [exec] Nucleus running
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004453     /     Unable to create class atg.deployment.server.DeploymentServer for configuration /atg/epub/DeploymentServer java.lang.NoClassDefFoundError: javax/ejb/FinderException
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /     Unable to resolve component /atg/epub/Configuration      java.lang.NoClassDefFoundError: javax/ejb/FinderException
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at java.lang.Class.forName0(Native Method)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at java.lang.Class.forName(Class.java:242)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.PropertyEditors.getPropertyEditor(PropertyEditors.java:254)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.BeanConfigurator.getProperty(BeanConfigurator.java:731)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.BeanConfigurator.configureStateProperty(BeanConfigurator.java:683)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.BeanConfigurator.configureStateProperty(BeanConfigurator.java:594)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.BeanConfigurator.configureState(BeanConfigurator.java:418)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.PropertyConfiguration.configureState(PropertyConfiguration.java:809)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.PropertyConfiguration.configureService(PropertyConfiguration.java:748)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.SingleNucleusConfigurator.configureService(SingleNucleusConfigurator.java:62)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.configureService(NucleusNameResolver.java:1319)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.configureAndStartService(NucleusNameResolver.java:1119)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:787)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:569)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:550)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.resolveName(NucleusNameResolver.java:394)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.resolveName(NucleusNameResolver.java:1051)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.ConfigurationRef.getValue(ConfigurationRef.java:81)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.ConfigurationRefProperty.getValue(ConfigurationRefProperty.java:82)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.SimpleComponentState.setBeanProperty(SimpleComponentState.java:357)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.SimpleConfigurationState.saveToBean(SimpleConfigurationState.java:218)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.SimpleConfigurationState.configureBean(SimpleConfigurationState.java:241)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.BeanConfigurator.configureBean(BeanConfigurator.java:275)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.PropertyConfiguration.configureService(PropertyConfiguration.java:752)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.SingleNucleusConfigurator.configureService(SingleNucleusConfigurator.java:62)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.configureService(NucleusNameResolver.java:1319)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.configureAndStartService(NucleusNameResolver.java:1119)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:787)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:569)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:550)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.resolveName(NucleusNameResolver.java:394)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.resolveName(NucleusNameResolver.java:1051)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.ConfigurationRefArray.getValue(ConfigurationRefArray.java:146)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.SimpleComponentState.setBeanProperty(SimpleComponentState.java:357)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.SimpleConfigurationState.saveToBean(SimpleConfigurationState.java:218)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.SimpleConfigurationState.configureBean(SimpleConfigurationState.java:241)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.BeanConfigurator.configureBean(BeanConfigurator.java:275)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.PropertyConfiguration.configureService(PropertyConfiguration.java:752)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.SingleNucleusConfigurator.configureService(SingleNucleusConfigurator.java:62)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.configureService(NucleusNameResolver.java:1319)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.configureAndStartService(NucleusNameResolver.java:1119)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:787)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:569)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:550)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.NucleusNameResolver.resolveName(NucleusNameResolver.java:394)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.Nucleus.resolveName(Nucleus.java:2648)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.GenericService.resolveName(GenericService.java:315)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.nucleus.GenericService.resolveName(GenericService.java:367)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.adapter.gsa.xml.TemplateParser.runParser(TemplateParser.java:5498)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /          at atg.adapter.gsa.xml.TemplateParser.main(TemplateParser.java:5072)
    [exec] **** Error     Wed Mar 07 10:20:04 EST 2012     1331076004484     /

    The class that is missing is javax/ejb/FinderException
    Download one of the jars from below site and add it to classpath. Then build the ear again and restart the server.
    http://www.jarfinder.com/index.php/java/info/javax.ejb.FinderException
    Peace
    Shaik

  • How to import a java class in a JSP

    Hi All,
    I have a java class file called myTest.class (i made after compilation of myTest.java). I have a JSP page that uses this java class file.
    These 2 files are in same folder called c:/test
    and iam importing this java class file into my jsp file and that too at the start of this jsp file:
    <%@page import="myTest" %>
    BUt iam getting an error ..............when iam running this JSP page:
    /opt/bea81sp2/user_projects/domains/wliDomain/./Managed2/.wlnotdelete/extract/Managed2_myTest_myTest/jsp_servlet/__test.java:20: '.' expected
    probably occurred due to an error in /test.jsp line 5:
    <%@page import="myTest" %>
    Please advise how to solve this problem
    -sangita

    Don't bother with the import
    when iam not importing this class file into my JSP, then on my JSP, the class file is not found.
    Here is my code: and these 2 class file are in c:/test
    import org.apache.tools.ant.taskdefs.Ant;
    import org.apache.tools.ant.taskdefs.Property;
    import org.apache.tools.ant.types.*;
    import org.apache.tools.ant.*;
    import org.apache.tools.ant.taskdefs.ExecTask;
    import org.apache.tools.ant.types.Commandline;
    import java.io.File;
    * Creates an Ant project to run an Ant build
    * @author myself
    * @version 1.0
    public class RunTest extends Ant {
        String applicationName;
        String buttonClicked;
        String boxName;
        String targetName;
        public void applicationName(String applicationName){
         this.applicationName = applicationName;
        public void boxName(String boxName){
         this.boxName = boxName;
        public void buttonClicked(String buttonClicked){
         this.buttonClicked = buttonClicked;
      public RunTest() {
    public void goTest() {
         if(this.buttonClicked.equalsIgnoreCase("deploy") && this.applicationName.equalsIgnoreCase("scsmail") && this.boxName.equalsIgnoreCase("testnet")){
           this.targetName = "deploy-scsmail-testnet";
         if(this.buttonClicked.equalsIgnoreCase("undeploy") && this.applicationName.equalsIgnoreCase("scsmail") && this.boxName.equalsIgnoreCase("testnet")){
           this.targetName = "undeploy-scsmail-testnet";
        Project project = new Project();
        project.init();
        System.out.println("printing 1 ....");
        ExecTask exec = new ExecTask();
        exec.setProject(project);
        exec.setExecutable("/opt/bea/weblogic81/server/bin/ant.bat");
         exec.setDir(new java.io.File("/export/home/beamon/bin"));
         Commandline.Argument arg = exec.createArg();
         // arg.setLine("-f scsmail.xml test -listener org.apache.tools.ant.XmlLogger -logfile D:/antProject/src/log.xml");
         arg.setLine("-f build.xml "+ targetName + " -listener org.apache.tools.ant.XmlLogger -logfile /export/home/beamon/bin/log.xml");
         System.out.println("printing 2....");
        //exec.setOutput(new File("D:/antProject/logs/prob.txt"));
        exec.execute();
        System.out.println("printing 3....");
    -----------------------the JSP page is called as test.jsp
    <%@page contentType="text/html" %>
    <%@page import="java.io.*" %>
    <%@page import="java.util.*" %>
    <%@page import="java.net.*" %>
    <%@page import="RunTest" %>
    <HTML>
    <TITLE>TESTING ANT GUI</TITLE>
    <HEAD>
    <META HTTP-EQUIV="Refresh" CONTENT="3000" >
    <meta http-equiv="Cache-Control" content="no-cache">
    </HEAD>
    <BODY BGCOLOR="silver" TEXT="333333">
    <table border=0>
    <tr align="left"><td align="left"><FONT SIZE="-1"><B>  Test Page <FONT SIZE="-1"><B></td></tr>
    </table>
    <hr></center>
    <form action="./test.jsp" method="POST" name="testForm">
    <table>
    <tr>
    <td>
    <select name="appName" size=1>
    <option value="">Select Application Name
    <option value="scsmail">scsMail
    <option value="clientmanager">ClientManager
    </select>
    </td>
    <td>
    <select name="boxName" size=1>
    <option value="">Select Box Name
    <option value="testnet">TestNet
    <option value="production">Production
    </select>
    </td>
    </table>
    <table>
    <input type="submit" name="deploy" value="deploy">
    <input type="submit" name="undeploy" value="undeploy">
    </table>
    <%
       RunTest rt = new RunTest();
       rt.applicationName(request.getParameter("appName"));
        String deployButton = "";
        deployButton=request.getParameter("deploy");
        String undeployButton = "";
        undeployButton=request.getParameter("undeploy");
        if(!deployButton.equalsIgnoreCase("")){
            rt.buttonClicked(request.getParameter("deployButton"));
        if(!undeployButton.equalsIgnoreCase("")){
            rt.buttonClicked(request.getParameter("undeployButton"));
       rt.boxName(request.getParameter("boxName"));
        rt.goTest();
    %>
    </form>
    </table>
    </BODY>
    </HTML>

  • Error while importing user created packages

    Hi ,
    Complexity--- Novice
    Problem Description
    I am trying to run a simple package related program.
    The package file is perfectly compiled and stored in the required path.
    When I try to access this package from another file -- the import statement does not seem to be working.
    It reports an error. However If I use the <pacakage>.<classname> it works perfectly fine.
    I have the following files
    1) The package file : Get.java
    2) The package accessing file : Test.java
    ///////////////Get.java/////////////////////
    package get;
    public class Get
         public Get()
         public String iGet()
              return("Hello World!");
    /////////////////////Test.java/////////////////
    import get.*;
    class Test 
         public static void main(String[] args)
              Get g= new Get();     //Here instead I use get.Get g= new get.Get() it works fine
              System.out.println("Hello World!");
    ///////////////////End of Files////////////////
    /////// Compiling/////////////
    c:\packages>dir *.java    //These are the only 2 files in the directory
    10/05/2005  12:02 AM               147 Test.java
    10/04/2005  11:55 PM               125 Get.java
    c:\packages>javac -d . *.java
    .\Get.java:3: duplicate class: get.Get
    public class Get
           ^
    Test.java:7: cannot resolve symbol
    symbol  : constructor Get  ()
    location: class Get
                    Get g= new Get();
                           ^
    2 errorsI think the problem is clearly explained.
    Thanks in advance

    When the file Test.java is compiled all it needs is
    get/Get.class
    There is no need for the file Get.java to be in
    get/Get.javaI agree with these two statements and it is true that using -d will create the Get.class in the correct directory. However, it looks like you might have Get.java in the Classpath and you are using "import get.*;" in Test.java. You may be confusing the compiler because javac will automatically try to compile source code for dependent classes. I think it will work if you change the import to "import get.Get;"

  • I dont understand creating classes they seem a waste of time and efficiency

    I dont understand why we would want to create classes with constructors and get and set statements... I know that VB and Java did not create these just to have us writing extra code so I am missing something in my thinking.
    I read about data hiding and that I understand I guess...but everytime my professors want me to create a class then create an object from that class to access it I dont really get it. I know how to do the basics of it but I can do all of it in my main or the primary class whats the benefit of creating a whole entire class such as the following?
    Everytime I get an assignment and they are like create a class and I try to rack my head for a good idea but the nearest analogy I can come up with is this... creating your own class seems like one of those old straws you drink out of with all the loops, yes you can make it go around in a big loop but why waste time? you want to get to point A to point B so create the most efficient way to get there if possible.
    I am sure the problem is I am not seeing something and there is some logic missing but I just am getting irritated as I am not seeing it and I am finding it, its like I add an extra obstacle course to my code for no other reason than to run through a bunch of extra tasks that I could perform in my main class or main.
    input is welcome to help me arrive at some type of enlightenment thanks
    Class may not be the correct wording for this as I know we have to have a class but what I mean is a non application class. The class I have below goes with another class that actually does a lot of stuff but I am forced to push data through this class that basically does nothing but run water through some different pipes if you will. To me thats a waste when I can do everything in my original class which was called menu that I am messing with and that creates an array for a user who wants to keep a list of his items and prices of those items in inventory.
    public class Item
    private String itemName;
    private double itemPrice;
              public Item()
    public Item (String item, double price)
    setName(item);
    setPrice(price);
    public String getName()
         return itemName;
    public void setName(String item)
         itemName = item;
    public double getPrice()
         return itemPrice;
    public void setPrice(double price)
         itemPrice= price;
    Edited by: Bricatw on Oct 30, 2009 10:33 PM

    What I was plugging into it and please forgive the code as its not finished... (I am still messing with it) its just for learning and I am required to have certain parts in the Item Class and Certain parts in the Menu class..... But you it pushes through the input to the java bean.... in a case like this I just dont see the need for doing it not that I can think of anyway.
    import java.util.Scanner;//my imports for scanner so can read from the screen
    import java.util.*;//imports for my array I used astrix to just import it all as the book said it does not have any negative affects.
    public class Menu //My application class Menu that contains my main
         public static void main(String[] args)//Main method
              final int NUMBER_Of_Elements = 30; //created a symbolic constant so that I only have to change the constant
              //to edit the size of the array if I should want to change it.
              Item[]inventory = new Item[NUMBER_Of_Elements];//I create a new array object with the constant as the number of elements.
              Scanner sc = new Scanner (System.in);//created object from the scanner class used to get input from the console screen.
              System.out.println("Please enter Item on first line and price on second line.");//outputted text to prompt user and give instructions.
              System.out.println("Enter STOP to exit");//instructions on how to exit the program. I would have rather used a different
              //word than stop here. If my choice I would have used "exit" as its more widely used and to promote uniformity.
              int count;//count variable used to count my loops very important as we use it to control our arrays and loops here.
              double price;//our variable that we plug in values from the user via the console.
              String item;//same as previously mentioned for the "price"
                        System.out.println("Wings Coffee Shop Menu");
              System.out.println("");
              System.out.println("Menu Item Price");
              for (count=0; count<inventory.length; ++count)//This is our for loop it uses the length method to control how many times
              //it runs. In this case inventory.length = 30 elements so would run 30 times unless it stopped early.
                   item = sc.nextLine();//reads the input from console into the item variable.
                   if(item.equalsIgnoreCase("STOP"))//if statement that states if = stop (ignores case sensitivity) then it will break out of the loop.
                   break;//the break command which is executed if the if statement is true.
                   price = Double.parseDouble(sc.nextLine());//
                   inventory[count]= new Item(item, price);
                   Item Call = new Item(item, price);
                   System.out.printf("%-13s %.2f\n", Call.getName(), Call.getPrice());
              System.out.println("Wings Coffee Shop Menu");
              System.out.println("");
              System.out.println("Menu Item Price");
    //           for(int x = 0; x < count; ++x)
    //           System.out.printf("%15s\n",inventory[x].toString());
    //                System.out.printf("%-13s %.2f\n", Call.getName(), Call.getPrice());
    //           String[] namesOfItems = {"Coffee", "Milk", "Soda", "Bagel", "Croissant", "Donut"};
    //           double[] prices = {3.99, 2.99, 2.49, 2.99, 2.49, 1.99};
    //           for(int x = 0; x < prices.length; ++x)
    //           System.out.printf("%-13s %.2f\n", namesOfItems[x], prices[x]);
    //           Item arrayPrice = new Item(); HOW COME I CANNOT CREATE THIS OBJECT?
    //           Item call = new Item ();
    //           Item Call = new Item("item", 4.9);
    Edited by: Bricatw on Oct 30, 2009 11:22 PM

  • Why do I get "generic error" message when trying to upload a self-created, 1hr .wmv file?

    I went through the forums and made sure that any blocks or copywrites weren't triggered by the file, it's clean and can be opened using a media player and other video editing software like windows MovieMaker. I keep getting "The importer reported a generic error" message and have no idea how to proceed. Can someone please help?

    Re: Why do I get "generic error" message when trying to upload a self-created, 1hr .wmv  file?
    This ARTICLE starts with a checklist on setting up a computer to run PrE best, then goes into a series of links for tuning up one's computer and OS, and then links on troubleshooting.
    There is also a link on posting all necessary info, to help others help you.
    Without knowing much more about your system, it is impossible to say much beyond that WMV's are tough assests to work with, requiring a lot of CPU horsepower.
    Good luck,
    Hunt

  • Problem sending self create MP4 (create on PC not Iphone)

    I have problem sending out self create MP4 which i have create on my PC.
    The MP4 was available in the ipod Video folder... but not my photo album.
    and more apps only can select video or photo from the photo album for posting/attachment..
    Anyway I can do to "transfer" the video from ipod video folder to the photo album?

    Oke thanks, I will replace the RuntimeExceptions where IOExceptions are needed. The problem occurs mainly in this portion of the code
    public class HandleForward implements Runnable
          * Runs the thread
         public void run()
              try
    //               //data back out to client
                   out.writeObject(bufferCBS);
                   out.flush();
                   System.out.println("Data to client: " + bufferCBS);
    }When I want to write data back to the client, then this does not work for me.

  • Failed to Call Self Written Class Files in JAVA 1.4

    While compiling java application in JAVA 1.4 environment, import command for self written class file fails even though classpath is set and declared during compilation.
    It flashes like ". is expected" Please help,
    Regards,
    Avijit Dutta (e-mail - [email protected])

    I had a similar problem with 1.4:
    since 1.4 java doesn't accept imports of "top-level packages" any more, i.e. classes, that don't belong to a package can't be imported in other classes.
    --> always put your self written classes into a package
    then you will be able to import them.
    hoschi

  • ADF : How to import a java class in jspx page

    Hi All,
    In jsp we have page directive to import a java class. Do we have anything similar to that in a jspx page?

    Hello,
    If you create a new jspx file in jdeveloper, the untitled file generated will be this:
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1">
    <jsp:output omit-xml-declaration="true" doctype-root-element="HTML"
    doctype-system="http://www.w3.org/TR/html4/loose.dtd"
    doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>
    <jsp:directive.page contentType="text/html;charset=UTF-8" import="java.util.*"/>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>untitled1</title>
    </head>
    <body></body>
    </html>
    </jsp:root>
    You can see the page directive there!

  • To Unable to Import Customize Java classes in Report Builder 10g

    Hi,
    In Report Builder 10g , I am trying to load image from Remote server
    URL:"http://imagecache5.art.com/p/LRG/15/1544/1ABDD00Z/muhammad-ali-vs-sonny-liston.jpg"
    Steps did in Report Builder 10g
    1.In Report Builder Created a Formula column with
    Datatype : Character
    Read from File: Yes
    File Format: Image
    In Formula columns trying to Unable to Import Customize Java classes.
    To read methods from Java classes.
    Please help on this.
    Ranga

    Hello,
    To import the Java classes:
    Add your jar in the REPORTS_CLASSPATH
    Launch Reports Builder.
    Note:
    You must launch Reports Builder now so that the new REPORTS_CLASSPATH is used.
    Choose Program > Import Java Classes to display the Import Java Classes dialog box.
    Regards

  • How to import GreenSock external classes?

    Hi, I'm having some problems in importing GreenSock external classes into my flash project.
    Line 27: import gs.*;
    Desktop\myFlashAPPS\twitter\src\zainu\twitter\MainClass.as, Line 27
    1172: Definition gs could not be found.
    Here is the directory tree:
    myFlashApp (contains myproject.fla)
         src
              zainu
                   twitter (contains MainClass.as and gs folder)
    MainClass.as:
    package zainu.twitter{

    You could try specifying the path to the gs folder as if you were importing it directly from the myproject.fla file.
    You should set up a classpath for external classes for your system so that Flash has a ready reference for finding them.  YOu can set this up via using Edit -> Preferences... -> Actionscript -> Actionscript 3.0 Settings... -> specify a source path.  Normally what people do is create a folder in a relatively general location and use that as their source path.   Within that they place a "com" folder, and within that com folder they place their subfolders for different classes they acquire from outside sources, such as your gs folder.  So when you want to import the gs classes you can use... import com.gs.*;
    There is a tutorial at gotoandlearn that explains this...   http://www.gotoandlearn.com/play.php?id=30

  • Cannot create class in system package

    Hello,
    I wrote a J2ME game for nokia S40 phones. It compiles without any errors, but when I'm trying to run in on the Nokia 7210 phone emulator I receive the following message:
    Cannot create class in system package.
    Howerver running on the Nokia 6230 phone emulator is ok.
    I have obfuscated my applet as I read in previous topics, but still it does not work.
    Can anyone help me?
    Thanks,
    Alexander.

    You get that error when you try to reference a class that is part of the MIDP framework but isn't installed on the phone.
    The 7210 doesn't support MMAPI or WMA or MIDP 2.0, while the 6230 does, so check that you don't have any references (even an import statement), to classes from those packages (like the javax.microedition.media.*, javax.microedition.lcdui.game.*,javax.wireless.messaging.*, etc. packages hierarchies).
    shmoove

  • Cannot create class in system package while Using Sprite class

    Hi i developed a game using Sprite class & imported
    javax.microedition.lcdui.game.*; package. But when i tried to build this project it gave me "Cannot create class in system package" error. Worst thing is that now again if i build, then it displays error "package javax.microedition.lcdui.game.*; does not exist" . Pls help me

    First exception means that you tried to create a class with the package name equaling one from the predefined libraries in midp/cldc.
    For your second error, add all the jars you are using into the project's classpath.
    Mihai

Maybe you are looking for