Package/class stuff

I have created the package further below and access it with
the code
immediately below. If I don't have any reference to TestMe it
works fine.
But when I try to add the TestMe function, I get the error
"Call to a
possibly undefined method TestMe"
I thought if I followed the example with TestClass by rote, I
could make the
additional function work. Can anyone tell me what I'm doing
wrong? Also,
with the little I know about AS, I do know that when using
the var statement
you define a variable and it's type separated by a colon. In
defining the
variable that runs the constructor, what follows the colon
and does it have
to be the name of the class? Also, if only the constructor
requires the
"new" keyword I though getting rid of the "new" in the TestMe
() function
call it would work. I got the same message.
HELP
import com.mysite.testing.TestClass
var testClass:TestClass = new TestClass();
var testMe:TestClass = new TestMe();
package com.mysite.testing{
public class TestClass {
public function TestClass() {
trace("TestClass working");
public function TestMe() {
trace("TestMeWorking");

After 3 hours of scouring the internet I finally found ONE
tutorial that
answered my question. Once the constructor is called, the
functions within
the class can be called using dot syntax with the class as
the root. So my
third line should be
testClass.TestMe ()
That would call the TestMe function within the testClass
class.
"WOMP" <[email protected]> wrote in message
news:frv41t$oej$[email protected]..
>I have created the package further below and access it
with the code
>immediately below. If I don't have any reference to
TestMe it works fine.
>But when I try to add the TestMe function, I get the
error "Call to a
>possibly undefined method TestMe"
>
> I thought if I followed the example with TestClass by
rote, I could make
> the additional function work. Can anyone tell me what
I'm doing wrong?
> Also, with the little I know about AS, I do know that
when using the var
> statement you define a variable and it's type separated
by a colon. In
> defining the variable that runs the constructor, what
follows the colon
> and does it have to be the name of the class? Also, if
only the
> constructor requires the "new" keyword I though getting
rid of the "new"
> in the TestMe () function call it would work. I got the
same message.
>
> HELP
>
> import com.mysite.testing.TestClass
> var testClass:TestClass = new TestClass();
> var testMe:TestClass = new TestMe();
>
>
> package com.mysite.testing{
> public class TestClass {
> public function TestClass() {
> trace("TestClass working");
> }
> public function TestMe() {
> trace("TestMeWorking");
> }
> }
> }
>

Similar Messages

  • Help! How to create Jar file for a packaged class?

    Hi!
    I am new in jar complexities. I made a swing frame that just prompts a JOptionPane when executed. I accomplished the same using jar without packaging my class SwingTest.
    But when i package it, it doesn't run. Can any one tell me how to make jar file of packaged classes and include images in the jar files too!
    Really Thanx!

    Call the Jar from the commandline to see the exceptions thrown.
    java -jar <jarFileName> <className>

  • Package Class in Transport Collector

    When i Collect my Objects in the Transport Collector, I find that many of them are attached to a different Package class. there many such sub objects too. some of them i changed by right click -> change object directory. but some 300+ objects are still residing in another package.
    CAN I change the same by updating a table called TADIR by writing an ABAP code ??
    Or shud i continue to manually change the class.
    Pls advice. thanks.

    Hi,
    if you change the object directory entry (e.g. package of an object), the SAP system is doing some more things than just changing the TADIR table: it is locking the object and connecting it to a transport request, also some checks are performed, e.g. whether the namespace of the package is allowed for the object. To avoid inconsistencies, I would <b>not</b> prefer writing an ABAP in this case.
    Stephan

  • Importing Inter-package classes

    hello
    I have never had this problem before but I just 'downgraded' to JDK 1.1.8 because the code will be used on my PDA. I am trying to import Inter-package classes but the compiler it cannot find the classes I've imported. This code was working perfectly in j2sdk1.4.2_02
    I think the code is right all files saved in folder graphs and beginning looks like this:
    package graphs;
    import graphs.AxisParameter;

    Yes they are in the same folder with 'package graphs;' in the 1st line,
    i've tried with and without package.class to no avail
    the exact errors i'm getting are
    without the package in front
    error: File .\CustomLabel.class does not contain type CustomLabel as expected, but type graphs.CustomLabel. Please remove the file or make sure it appears in the correct subdirectory of the class path
    with the graphs.CustomLabel i get the following errors
    error: Invalid class File formate: .\graphs\CustomLabel.class, wrong version: 46, expected 45
    2nd error: Class graphs.CustomLabel not found in import.

  • //package classes;

    i have used the code below,,and my application is working fine...but when i removed the comments from the package ling..the 404 error is coming..i have compiled the servlet with package line uncommented..whats the reason?
    //package classes;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.io.*;
    import java.sql.*;
    public class CookieLoginServlet extends HttpServlet {
         public void doGet(HttpServletRequest request ,HttpServletResponse response)
         throws ServletException,IOException {
              sendLoginForm(response,false);
              System.out.println("inside get");
         public void doPost(HttpServletRequest request,HttpServletResponse response)
         throws ServletException ,IOException {
              String userName=request.getParameter("userName");
              String password=request.getParameter("password");
              if(login(userName,password)){
    Cookie c1=new Cookie("userName",userName);
    Cookie c2=new Cookie("password",password);
    response.addCookie(c1);
    response.addCookie(c2);
    response.setContentType("text/html");
    PrintWriter out =response.getWriter();
    // response.sendRedirect does not work here.
    // use a Meta tag to redirect to ContentServlet
    out.println("<META HTTP-EQUIV=Refresh CONTENT=0;URL=ContentServlet>");
              }else{
                   sendLoginForm(response,true);
         private void sendLoginForm(HttpServletResponse response,boolean withErrorMessage)
         throws ServletException ,IOException {
              response.setContentType("text/html");
              PrintWriter out=response.getWriter();
              out.println("<html>");
              out.println("<head>");
              out.println("<title>Login</title>");
              out.println("<body>");
              out.println("<center>");
              if(withErrorMessage){
                   out.println("login failed .plz try again<br>");
                   out.println("if u think you have entered the correct user name "+
                        "and password,the cookie setting in your browser might be off " +
                        "<br>Click<a href=InfoPage.html>here</a> for information ");
              out.println("<br>");
              out.println("<br><h2>please enter your username and password</h2>");
              out.println("<br>");
              out.println("<br><form method=POST>");
              out.println("<table>");
              out.println("<tr>");
              out.println("<td>userName:</td>");
              out.println("<td><input type=text name=userName></td>");
              out.println("</tr>");
              out.println("<tr>");
              out.println("<td>password:</td>");
              out.println("<td><input type=password name=password></td>");
              out.println("</tr>");
              out.println("<tr>");
              out.println("<td><input type=submit value=submit></td>");
              out.println("</table>");
              out.println("</form>");
              out.println("</center");
              out.println("</body>");
              out.println("</html>");
         public static boolean login(String userName,String password){
              try{
                   Class.forName("sun.jdbdc.odbc.JdbcOdbcDriver");
                   Connection con =DriverManager.getConnection("jdbc:odbc:JavaWeb");
                   Statement s=con.createStatement();
                   String sql="SELECT UserName FROM users" +
                   "WHERE UserName='"+fixSqlFieldValue(userName)+ "'"+
                   "AND password='"+fixSqlFieldValue(password)+"'";
                   ResultSet rs= s.executeQuery(sql);
                   if(rs.next()){
                        rs.close();
                   s.close();
                   return true;
                   }else
                   {     rs.close();
                   s.close();
                   con.close();
              }catch(ClassNotFoundException e){
                   System.out.println(e.toString());
         catch (SQLException e) {
         System.out.println(e.toString());
         catch (Exception e) {
         System.out.println(e.toString());
         return false;
         public static String encodeHtmlTag(String tag){
              if(tag==null)
              return null;
              int length=tag.length();
              StringBuffer encodeTag=new StringBuffer(2*length);
              for(int i=0; i<length; i++) {
              char c=tag.charAt(i);
              if(c=='<')
              encodeTag.append("<");
              else if(c=='>')
              encodeTag.append(">");
              else if(c=='&')
              encodeTag.append("&");
              else if(c=='"')
              encodeTag.append(""");
              else if(c==' ')
              encodeTag.append(" ");
              else
              encodeTag.append(c);
              return encodeTag.toString();
         public static String fixSqlFieldValue(String value) {
              if (value==null)
              return null;
              int length = value.length();
              StringBuffer fixedValue = new StringBuffer((int) (length* 1.1));
              for(int i=0; i<length; i++) {
              char c = value.charAt(i);
              if(c=='\'')
              fixedValue.append("''");
              else
              fixedValue.append(c);
              return fixedValue.toString();
    }

    It means you didn't deploy the servlet properly.
    Put the package back - all your Java classes should go into packages. All the time. The only exception is when you're writing a quick knock-off to test something that you'll run on the command line and rarely use again.
    No surprise - the code you've written is certainly terrible. HTML to the output stream - ever heard of JSP?
    SQL code in a servlet - ever hear of Data Access Objects?
    Layering apps makes them easier to test, debug, maintain, and understand.
    What servlet/JSP engine are you using? Tomcat? If so, Tomcat requires that you use packages.
    Where did you put this beauty of a servlet? Better not be /ROOT. Create a directory under /webapps for your app and deploy it there.
    What URL did you use to invoke the servlet? I'll bet that's wrong, too.
    Lots to correct here.
    %

  • Compiling java package class referring a default package class.

    I am trying to compile a java class having a package defination referring a java class with a default package.
    The code for the default package class is .
    public class Test{.
    public static void main(String[] args){
    System.out.println("Hello World!");
    This class compiles fine.
    I have another class called PackJava, whose code is :
    package test;
    import Test;
    public class PackJava{
    public static void main(String[] args){
    Test test = new Test();
    System.out.println("Hello World!");
    I have Test file in the windows path
    D:\development\packagetest\example
    and the PackJava java file in the path
    D:\development\packagetest\example\test
    I have set the CLASSPATH environment varibale as
    D:\development\packagetest\example;.
    When I try to compile the PackJava from the
    D:\development\packagetest\example path giving the command as
    javac -classpath . test\PackJava.java
    or
    javac -classpath %CLASSPATH% test\PackJava.java
    it gives me error,
    Do any of you have an idea of the parameter i should pass
    to the -classpath option
    Thanks

    There is a way around all this. The classes in the default packages need to implement an interface with the methods require. The interface can be in any package you want ie. com.work.around.interf.MyInterface1. Next, make this interface available in a Singleton. - The only catch here is that, the main method must reside in default package as well. And o, on start of main, instantiate the class you want and put it in the singleton. There after, you may refer to it from the singleton.
    Enjoy.

  • [svn] 3403: Fix for SDK-17097 - Missing summary description of a class in package classes table

    Revision: 3403
    Author: [email protected]
    Date: 2008-09-29 12:36:37 -0700 (Mon, 29 Sep 2008)
    Log Message:
    Fix for SDK-17097 - Missing summary description of a class in package classes table
    QA: Yes
    Doc:
    Tests: checkintests
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17097
    Modified Paths:
    flex/sdk/trunk/asdoc/templates/class-files.xslt

    Well, it's kind of logical that as you put more jar files (classes) in Tomcat, it changes the error to ask for the classes (inside a jar) it cannot find.
    There was a good class->jar finder on the internet some years ago, but i don't remember the address. Try looking for that and search all the missing classes (NotDefined) and their correspondig jar files.
    Good Luck!

  • Package/class which gives currency exchange rates

    Is there any package /class in Java which gives the current currency exchange rate ? If not how can this be achieved?

    you'll have to find an online provider of that information and write code
    to subscribe to the information. Up to the minute rates will probably cost you as well.

  • Work on FB4.5 and Flash5.5 simultanoiusly - lack of code hints and default package classes.

    Hi!
    I setup Flash Professional CS5.5 and FB4.5 to work together. I just followed this tutorial: http://www.adobe.com/content/dotcom/en/devnet/flash-builder/articles/sharing-projects-flas hbuilder-flash.html and almost all looks good, but unfortunately working in Flash Builder adding new Classes I do not have default package Classes accessible. This way I can not even declare Sprite, Array class and so on. In code hints I only gets my current package classes.
    I set the .fla project inside Flash CS5.5 with some folders as the package for my classes. It is for examle:
    com.myDomain.testProject where DocClass exists. By adding this path as the document for FlashCS5.5 all works great, I can easily run, debug movie in the Flash environment.
    Setting this project by 'Import'->'FlashBuilder-FlashBuilderProject'->'ProjectFolder' pointing to the .fla file it seems that the thing goes well. The project is set and even I had some problems with Document Class's name (it seems that Flash Builder need to have Document Class with the same name as the .fla flie) and renaming it I can run or debug it and it works.
    But if I try to add new class to the directory I end up with no code hints, and in fact no default package classes support. That means I get errors trying to create instance of any common class etc. In code hints I am only getting my package hints (look picture)
    Maybe I misunderstand of some package basics and did something wrong, but generally I don't want to put all my classes to the .fla location but to sort them up in specific folders cause I assume that the project is quite large.
    If you can help me, thanks in advance. You know messing up with the code is a part of the programmer nature, and when one finds the answer he feels like a king. When to deal with environments like that, there is never joy and hapiness, but in most occasions couple uncensural words in the end, and a glimpse on the watch - agrrrhh I lost so much time :/
    cheers

    upss, It seems the Flex sdk wasn't added automatically what I didn't noticed. Looked for errors in some other areas (as always)
    Thanks anyway:)

  • Eclipse - how to share a package/class with 3 diff projects

    Hi all,
    I have 3 projects that are customized diffrently but one package is same for everyone (sharedClass). The problem is when I add/delete/update the SharedClass I have to do it 3 times (for each project)
    Question: How can I share the package/Class with the 3 projects? I mean, I want to change it once and the effect will take place to all 3 PROJECTS.
    Thanks
    Ppr

    This is an Eclipse question and doesn't really belong here, but:
    I would put the shared package into its own project. Then for the three projects (after removing the shared package) I would use the Project menu and choose properties. Choose Java Build Path snd select Projects. Choose Add and select the project containing the shared package.

  • Package+class=?

    Hi,
    i am confused with formal name of package+class.
    E.g: java.awt.Frame
    do you call it:
    1. full qualified class name
    2. qualifier
    3. full name
    or something else?
    I think there must be a simple, single and formal word for it?
    what is that word?

    I would just call it the "fully-qualified class name". Is this a test question to trip someone up?

  • Instantiation order: package , class , function

    hello;
    I have a document class, booger.as:
    package
    trace( "package " );
    import flash.display.Sprite;
    public class booger extends Sprite
    trace( "class " );
    public function booger ()
    { trace( "function " );
    I would expect the firing order to be:
    package
    class
    function
    but the output says otherwise:
    class
    package
    function
    any thoughts?
    thanks
    dsdsdsdsd

    Sweet! Thanks. I am not used to creating an instance of a
    class since my background is from mostly VBA programming. I had the
    import statement, but not the variable creating an instance of my
    timer class. I kept trying to simply call the function by using its
    name in the click event of a button. It all makes sense now.

  • The "Package" class

    Hi all,
    Why the java.lang.Package class is not declared final?
    Thanx,
    Adrian.

    I will give you an example:
    During two weeks I'm trying to understand the
    class-loader mechanism.
    I read every possible article I could found - and
    still I find that it
    is a mysterious design. That's because the Java
    platform (as Microsoft's platform) is an evolving
    platform, and today's solutions come to repair
    yesterday's mistakes.
    Yet, another example is AWT/Swing.Maybe you don't understand the meaning of 'bloated' because being "mysterious" has nothing to do with being bloated. The class-loader mechanism is not mysterious to me and I don't see why Package not being final makes it mysterious. It's impossible to extend Package so making it final wouldn't have any functional effect, though, for completeness it would make sense to mark it final.

  • Running a packaged class

    how do you run a packaged class? it always gives me
    Exception in thread "main" java.lang.NoClassDefFoundError: Engine (wrong name: jad/game/thread/Engine)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    Could not find the main class: Engine.  Program will exit.
    Press any key to continue . . .i've tried calling it from its packeged name and everything but it always says it cant find it.

    Please show your java command.
    It probably should be something like (ignoring classpath for the moment)
    java jad.game.thread.Engine
    .Edited by: cotton.m on 23-Mar-2009 7:10 PM

  • When try to import a packaged class it alway complain package does not exis

    when try to import a packaged class it alway complain package does not exisist??
    pls help

    when try to import a packaged class it alway complain
    package does not exisist??Even with the bootstrap classes? "import java.lang.Double;" gives you the same error?
    If not, please check your classpath.

Maybe you are looking for