Using packages?
Hello,
Could anyone advise? My Test.java file includes the import line:
import examples.java.code.*;
The example folder is on the my hard drive at, c:\swing\examples\java\code
Please note the Test.java file is based at c:\swing
And all the java files in the code folder, include:
package examples.java.code;
But when I try to compile in windows dos using:
c:\swing\javac -classpath c:\swing\examples\java\code Test.java
The error I get is:
C:\SWING>javac -classpath c:\swing\examples\java\code Test.java
Test.java:1: package examples.java.code does not exist
import examples.code.java.*;
Could anyone see the problem?
Thank you
Sorry that was my mis-typing,
C:\SWING>javac -classpath c:\swing\examples\java\code Test.java
Test.java:1: package examples.java.code does not exist
import examples.java.code.*;
The compiler error is as above and the import line is:
import examples.java.code.*; in the Test.java file.
I also tried c:\swing\javac -classpath. Test.java and java said the format of the line was wrong.
Similar Messages
-
How can i call a method from the a subdirectory using packages
This is my directory structure:
java
--p1
--One.java
--p2
--Two.java
package java.p1;
import p2.Two;
public class One
public static void main(String args[])
Two obj = new Two();
obj.p();
package java.p2;
public class Two
public void p()
System.out.println("p method");
ERRORS !!
C:\Documents and Settings\ashutosh\Desktop\java\p1\One.java:3: package p2 does not exist
import p2.Two;
^
C:\Documents and Settings\ashutosh\Desktop\java\p1\One.java:9: cannot find symbol
symbol : class Two
location: class java.p1.One
Two obj = new Two();
^
C:\Documents and Settings\ashutosh\Desktop\java\p1\One.java:9: cannot find symbol
symbol : class Two
location: class java.p1.One
Two obj = new Two();
^Help me out. Thanks.jinchuriki123 wrote:
This is my directory structure:
java
--p1
--One.java
--p2
--Two.java
package java.p1;
import p2.Two;
public class One
public static void main(String args[])
Two obj = new Two();
obj.p();
package java.p2;
public class Two
public void p()
System.out.println("p method");
ERRORS !!
C:\Documents and Settings\ashutosh\Desktop\java\p1\One.java:3: package p2 does not exist
import p2.Two;
^
C:\Documents and Settings\ashutosh\Desktop\java\p1\One.java:9: cannot find symbol
symbol : class Two
location: class java.p1.One
Two obj = new Two();
^
C:\Documents and Settings\ashutosh\Desktop\java\p1\One.java:9: cannot find symbol
symbol : class Two
location: class java.p1.One
Two obj = new Two();
^Help me out. Thanks.You don't have a class p2.Two, You do have a class java.p2.Two. Package paths aren't relative.
Also, it's recommended not to use package names containing "java" or "javax" (or is it illegal to do so?). Change your package & folder names.
db -
I am trying to use a package constant in a query as follows:
SELECT field1 FROM table t WHERE CEIL(sysdate - t.field2) > schema.package.constant
field1 is a name
field2 is a timestamp
constant is an integer indicating the expiration time in days
basically I am trying to find all expired items.
I get the error "ORA-06553: PLS-221: 'constant' is not a procedure or is undefined" on this query.
I use this same query as a cursor in the package itself with no errors.Unfortunately you cannot directly use package global variables in select statements like this.
One workaround is to use bind variables for that:
<p>
SQL> CREATE OR REPLACE PACKAGE pkg
AS
myconstant VARCHAR (20) := 'This is my constant';
END pkg;
Package created.
SQL> VAR myconstant VARCHAR2 (20)
SQL> EXEC :myconstant := pkg.myconstant
PL/SQL procedure successfully completed.
SQL> SELECT :myconstant
FROM DUAL
:MYCONSTANT
This is my constant -
Using packaged functions in Apex
Hi,
I'm fairly new to apex and I am about to write an app which needs to access a SQL server database. My local dba has set up the transparent gateway and I can select from and update the SQLServer database no problem via a db link. What I need to decide is whether to code the sql for reports etc directly into the apex page or to call a pl/sql function returning a select statement. I would like to have all the code in packages as a lot of it will be used by multiple apps in future but is there any extra overhead in doing this:
declare
l_sql varchar2(4000);
begin
select package.function into l_sql from dual;
return l_sql;
end;
rather than coding the SQL directly in the page? Also is there a more efficient way of using packaged functions to select data rather that just have it returning sql statements.
Thanks in advance.
DaveHi
I only use function returning select when I have a strong reason to do so, because it is so much more difficult to test and maintain. Not sure about performance, but I think it is not that much worse.
If you simply want to reuse SELECT statements, you could use views instead.
Anyway, if you decide to use the package solution, at least you can make it much simpler -- just code like this in the page:
return package.function;
I hope this helps.
Luis -
hi!
I am new to java .... learning how to use packages. I have created dir on my harddrive c:\learning\java ... in which i have created com\tests.... added c:\learning\java to path env variable .... And have written two java programs.
1. jmain.java
adds two integers and puts in another integer
public int sum()
2. jtest.java
main method ... and creates an object of jmain class ... and uses
jmain jm = jmain();
jm.sum();
Both these classes are in the same package com.tests and both jmain.java uses package com.tests;
and jtest.java uses package com.tests; import com.tests.*;
3. jmain compiles alright
but when compiling jtest.java compiler gives an error saying can't resolve symbol
symbol : jmain.class
path : com.tests.jtest
What to do now ???????? when i went to check my directory structure ... i am doing everything right.... using case okay, path is okay, etc
still running errors .... please suggest a solution.
thanks.I tried this ... it's giving me same error.
Please help.
I am on winXp so i added at the end of my path env var .... c:\learning\com\tests
//jmain.java
package com.tests;
public class jmain
public int x=4;
public int y=66;
public int sum = x+ y;
public printsum ()
System.out.println(sum);
//jtest.java
package com.tests;
import com.tests.*;
public class jtest
public static void main(String [] args)
jmain jm = jmain();
jm.printsum();
Above is my program. Both java files are in C:\learning\com\tests
And, is there a difference between CLASSPATH and setting environment variable or system variable ???? What is SOURCEPATH too ???
Please help
Thanks in advance. -
Using package constants in package SQL - acts as bind variable or literal?
I'm looking for confirmation on the performance impact of using package constants in package SQL.
Let's say I have a number of queries in package code that refer to various literals that are prone to typos e.g. "CANCELLED" instead of "CANCELED". To reduce the chances of this happening, I have an APP_GLOBALS package where I declare constants for each literal:
C_CANCELED CONSTANT VARCHAR2(12) := 'CANCELED';And in queries that refer to literal 'CANCELED' I use APP_GLOBALS.C_CANCELED instead. This way the typo is caught during compilation. For example:
BEGIN
--Do something with all 'Canceled' orders
FOR r IN (SELECT order_id
FROM orders
WHERE status = APP_GLOBALS.C_CANCELED)
LOOP
END LOOP;
END;Assume that:
- the STATUS column is indexed
- the possible values are PENDING, APPROVED, CANCELED
- a small percentage of orders are CANCELED
From the optimizer's perspective is the query equivalent to
SELECT order_id
FROM orders
WHERE status = :varor
SELECT order_id
FROM orders
WHERE status = 'CANCELED'?
According to what I see in v$sqltext_with_newlines, it's the first one. Can anyone suggest an alternative way of replacing literals in package SQL to prevent typos? Worst case, I suppose I can start with constants so that it compiles successfully then do a global replace of the constants with the literals.Can anyone suggest an alternative way of replacing literals in package SQL to prevent typos?I cannot think of any. But, here is the thing. If the typos are there, then, it technically is a bug even though both the codes would compile. The bug will be hunted down when the program doesn't work as intended. Wouldn't most typos be caught in unit testing of the code?
Also, if you replace a string literal with a variable, then, maybe (just maybe, depending on your version of the dbms), it may end up picking a different execution plan. That might be an unintended consequence. -
How packages A uses packages B, Please?
Dear All
I have two packages and like to have the classes in A uses the Classes in B, A and B are seperate packages and each is compsed of many classes. My IDE is NetBeans 4.0, just if that important.
Please let me know how I can uses Package B classes as easy as importing jar files.
Cheers, khalidok I will try this, I understand that you mean when
both packahes a and b ar ein the same directory.Has nothing to do with whether the packages are in the same directory: You always provide the full package name in the import statement. Go through a tutorial or two, carefully. ...\com\mycompany\foo\Bar.class
...\com\mycompany\baz\quz\Splort.class
// For Bar to use Splort:
package com.mycompany.foo;
import com.mycompany.baz.qux.Splort;
public class Bar {}
// For Splort to use Bar:
package com.mycompany.baz.qux;
import com.mycompany.foo.Bar;
public class Splort {}
One
more to ask, What about when many classes in package
b.You can use import whateverpakcage.*; It's generally considered more maintainable to list individual classes though.
import a.B;
import a.C;
// etc. -
Using packages breaks batch file
Hi there, I wonder if anyone can help me here.
I've been continuing work on somebody else's previous project, and everything is fine except for the batch file used to run the program from non development. I decided to use Eclipse to develop as opposed to the previous JCreator, and Eclipse gave an error unless I used packages, however this breaks the batch file
Here's the orginal text from the batch file -
java.exe -Xmx256m -classpath C:\InsTra\JARS\ant.jar;C:\InsTra\JARS\jaxen-core.jar;C:\InsTra\JARS\jaxen-jdom.jar;C:\InsTra\JARS\jdom.jar;C:\InsTra\JARS\saxpath.jar;C:\InsTra\JARS\xalan.jar;C:\InsTra\JARS\xerces.jar;C:\InsTra\JARS\xml-apis.jar;c:\InsTra\code_files InsTra
The batch file is located in C:\InsTra, the external JARS are in a JARS subfolder, and the java and class files are in Code_files. The main class is InsTra. I get the error NoClassDefFoundError
I've tried making the last bit Code_files.InsTra in case it needed to reference the package, but I'm new to this I'm afraid so have little experience of this sort of thing.
Any help is welcome
Thanks
DanielThen either your compiled class is not on the classpath, or you have not used the correct class name. Or both.
The classpath must point to the root of the package hierarchy.
The class name must include the package name (which is dictated by the package line at the top of your source file).
The compiled class file must be in the correct directory.
Given the information that you have provided, your class file should have the following path:
c:\InsTra\code_files\Code_files\It should also have the following line at the top of the .java file:
pacakge Code_files;Class names are case sensitive. Remember that the class path points to the root of the package hierarchy, NOT each of the directories containing class files. For example, if your classpath is thus:
c:\fooYour class file is in:
c:\foo\foo\Spong.classWith a package of:
package foo;And you execute it with:
java -classpath c:\foo foo.SpongThen it will work. The following will not:
java -classpath c:\ foo.Spong
java -classpath c:\foo\foo Spong
java -classpath c:\foo\foo foo.Spong
java -classpath c:\foo\foo Spong.class
etc. -
Updating a JAR that uses packages
Hi There,
I have a problem in that I am trying to update a class within a JAR which uses packages. The issue is that when updating the JAR, the class I have requested to update is simply placed in the root of the JAR and not in the required package.
I need to to this within a Java program, so unpacking and re-packing the JAR is not an option.
Here is what i've been trying:
I have a class called UserProfile.class, which resides within my messages package - Structure: /messages/UserProfile.class
When I call the update command:
jar uf C:\AdminUI.jar E:\project\code\Eclipse_Proj\messages\UserProfile.class
It creates the folder structure /project/code/Eclipse_Proj/messages within the JAR file and places UserProfile.class within this folder - when in fact the UserProfile.class should be placed within the /messages folder.
Any ideas on how I can place the class in the correct folder would be much appreciated.
Thanks very much
K
nullThanks for the reply!
Yeah that works, but i'm trying to update the JAR from a Java program using
Runtime.getRuntime().exec()
but when I try to run the command Runtime.getRuntime().exec("cd c:") I get the below exception:
java.io.IOException: CreateProcess: cd c: error=2
I understand there is a -C parameter to temporarily change directory so I tried the following command:
jar uf C:\AdminUI.jar -C E:\project\code\Eclipse_Proj \messages\UserProfile.class
But this simply inserts the UserProfile.class into a jar under the following directory structure:
project/code/Eclipse_Proj/messages/UserProfile.class
Thanks again for your help.
Any input much appreciated
K -
Hi,
Created an installer i.e, meta package using package maker tool. I want to prevent downgrading of the application or package on the target/installed volume.
Problem is, if there is a newer version of app and when I try to install any older version, then it does not throw any error message to the end user and replaces the existing newer version with the older version of app, which should not happen. But, if I check the package version using version comparison of Package maker tool, that works fine with flat packages i.e, with the .pkg files. So, I need the solution for metapackages(.mpkg) and want to prevent downgrading of app for metapackages. I am not getting any solutions for this. Can someone guide me on this?
Thanks for the help provided.
Hi,
Created an installer i.e, meta package using package maker tool. I want to prevent downgrading of the application or package on the target/installed volume.
Problem is, if there is a newer version of app and when I try to install any older version, then it does not throw any error message to the end user and replaces the existing newer version with the older version of app, which should not happen. But, if I check the package version using version comparison of Package maker tool, that works fine with flat packages i.e, with the .pkg files. So, I need the solution for metapackages(.mpkg) and want to prevent downgrading of app for metapackages. I am not getting any solutions for this. Can someone guide me on this?
Thanks for the help provided.
-
Problem connecting to Oracle 8i (817) using Packaging Wizard of 9i Lite
I am having a problem to connect to Oracle 8i database (817) from using Packaging Wizard. I am getting a error message when I tried to use Packaging Wizard -> Snapshot -> Import -> Username/password and jdbc:oracle:oci8:@connect string or jdbc:oracle:thin:@host:1521:Sid
The error message is 'No Suitable Driver. Make Sure the Proper JDBC drive for "jdbc:oracle:oci8i:@<connect string>" is in the classpath"
I would appricated if someone can send me any help on this.
My email address is [email protected]
Thanks
JoshuaI am having a very similar problem.
It seems that the packaging wizard forces you to use a JDBC driver to connect to your DB.
I'm getting the "No suitable driver" message also.
I even made sure the classpath line they ask you to remove in the preinstallation tasks was there. It wasn't to start, so I added it, but that didn't fix the problem. -
Update Multiple Records by Using Package..
Hi All,
I have designed OA page which contains multiple records in a tabular format and few fields are editable. Now I want to update few records by using package. Bcoz page view object is too much complex. So it is impossible to create view object from EO. That’s why I want to update some value by using package.
Please help me…
Thanks in advance..
Thanks
--SubhasHi,
Use plsql record type for this type of requirement.
Refer folllowing steps:
1) Create a plsql record type in the database ,
2) create a plsql procedure/package and use above record type as parameter in the procedure.
3) call this procedure from OAF side.
Thanks,
Kumar -
CQ doesn't pick up nodetypes.cnd changes using Package Manager
Hi,
CQ doesn't seem to pick up the changes in custom nodetype definitions in nodetypes.cnd when I install the package containing the updated nodetypes.cnd using Package Manager, how do I get around this?
Steps
1) fire up a fresh installation of CQ
2) In Package Manager, upload a CQ package containing custom nodetypes.cnd
3) check that the custom nodetypes are registered in Node Type Administration console
4) change nodetypes.cnd by adding a new property in a custom nodetype inside nodetypes.cnd file
5) make a new package with updated nodetypes.cnd file
6) In Package Manager, upload the new CQ package and install
7) check that the new property has been added in Node Type Administration console <-- ***FAIL***
Thanks!You can only install new node types this way - but you cannot change existing node types with cnd files in a package. The package manager simply skips all existing namespace & node types in a cnd file.
This is because updating an existing node type might fail, depending on whether it is used in content and the change is conflicting. It's a schema change and that can be non-trivial. Therefore package manager does not try to tackle this at all.
You can use this tool that guides through the process: http://localhost:4502/libs/cq/compat/components/ntupgrade.html
You can do it yourself programmatically using the JCR API - take a look at the implementation of the above tool: /libs/cq/compat/components/ntupgrade/ntupgrade.jsp
But only do this during development - you should not plan for schema updates to production systems. In general, you want to minimize the use of schemas / node types with JCR. Use nt:unstructured, cq:Page, sling:Folder and co, and use properties (mostly sling:resourceType) to mark types. These can be much easier migrated.
HTH,
Alex -
How can I compile program which uses packages?
Hi,
I'm building a program using JBuilder9. I can successfully run using that IDE, but after I try to run it manually (run class file which compiled from JBuilder) by typing "javac myMainClass" it cannot find serveral packages which I put those packages' folder on the same root directory of myMainClass. Thank you.Man, you should probably read the following:
http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html
Anyways, the first thing to do is to determine the current value of CLASSPATH (that is a system variable and it depends on your OS how you change/get its value).
Next thing is to determine WHAT you need to add:
For each used package check if its (root directory/jar) is in your CLASSPATH. If not add it, e.g.
- you have a package my.test.package in C:\temp\myJar.jar then add C:\temp\myJar.jar
- you have a package my.test.package in C:\temp, i.e. your fs structure is C:\temp\my\test\package, then add C:\temp
For beginners, it's usually a good idea to have your CLASSPATH contain a dot (".") ... -
Cant use packages/classpaths correctly _ never could too
Hello,
I have a directory C:\DIR
In this directory I have a program. Two files both declare the package a.b package a.b;. Both files are in the directory C:\DIR\a\b.
One of my files is KeyInput.java which implements KeyListener for obvious reasons.
The second file is Main.java which has a Frame frame to which I want to add a KeyListener: frame.addKeyListener(new KeyInput()); Now, this works perfectly fine when I have KeyInput as an inner class, but using this (the above) architecture my compiler can't find KeyInput.
I have not set a classpath (though I did try that in my compiling command "javac -classpath C:\ Main.java", but that did not work).
I did check all sorts of documentation on this, so please don't answer that I should do just that. I can't get it running. Until now my remedy was not using packages, but I want to.
Please tell me what I am doing wrong,
Q
thanksI now have another basic problem with these two classes, which concerns the concept "static".
Here's the problem:
When I add a KeyListener to frame as above I instantiate a KeyInput.
In KeyInput I for instance want to use a key to quit the program. (I also want a lot of other things, but
the same problem applies to them) To do this I create a method "public void kill( )" in Main. mainInst is
an instance of Main (created in the public static void main (String[] args) method), but my instance of KeyInput does not know him.
So now I have a problem. Because I either have to make my instance of KeyInput know mainInst so it
can do "mainInst.kill( )", which I do not know how to do; or I have to use the Main class itself. However:
Main.kill( ) does not work, because kill isn't static. I could make kill static, but then I have a static context
where I don't want any, for know I have a boolean running which has to be declared static etc. etc., and
then I'm not even talking about all the other things to do with the keys.
Ok, one solution is simple... make KeyInput an inner class of Main. But I don't want that! It will wreck
all the little beauty present in my programmature. So what do I do? How does a professional do this? It's such a basic problem I must know the answer.
Many thanks,
Q -
Parallel Processing framework using package BANK_PP_JOBCTRL
Hi All,
I am analyzing differnt parallel processing techniques available in SAP and need some input on Parallel Processing framework using package BANK_PP_JOBCTRL.
Can someone please let me know if you have any documentation available with you on this framework.
I have couple of questions on this framework as mentioned below.
1) This framewrok was develped as part of SAP Banking soltion. So is it possible to leverage it for other modules in SAP since now it is part of SAP_ABA component.
2) What are the benfits of it over other technique like asynchronous Remote function call (aRFC).
Any inputs on this will be of great help since there is very less documentation available on this topic on net.
Regards/Ajay DhyaniHello,
Apologies, never saw this thread and your query and i already worked it out myself during the time i posted it . If you are still interested here are some of the inputs for you.
With in package bank_pp_jobctrl , you will find these FM. I have mentioned the use of it as well.
RBANK_PP_DEMO_GENERATE_DATA: To create the Business data for Parallel Processing.
RBANK_PP_DEMO_CREATE_PACKMAN: To create Packages out of the business data.
RBANK_PP_DEMO_START : To process data in parallel.
RBANK_PP_DEMO_RESTART: To re-process failed records during parallel Processing.
You will need to call above in your report program in the same sequence as shown above based on you requirement. I did used only first three.
TO generate events you will need to execute SE38: RBANK_PP_GENERATE_APPL to create application this will create the FM with numbers as shown below.
Events: This PPF automatically triggers various events during the execution of the Start Program. Each of this event is associated with a custom function module which contains the business logic.
For implementing this framework, at least the below mentioned methods should be implemented .
0205 – Create Package Templates : This method is used to write the logic for creating packages which in turn decides the data to be processed in parallel. This function module is called in loop at the loop ends only when the exporting parameter E_FLG_NO_PACKAGE has a value ‘X’ passed back to the Parallel processing framework.
1000 – Initialize Package :This method is the first step in processing a package. It fetches all the parameters required for the parallel processing to start. All the parameters are passed to this FM as importing parameters and it is the responsibility of this FM to save it in global parameters so that it can be utilized by Parallel processing framework.
1100 – Selection per Range : This method is used to read data for a package. The objects selected must be buffered in global data areas of the application for later processing. The package information is stored as interval in global parameters and this information is used to select the package specific data.
1200 – Selection for Known Object List: This method is used instead of method 1100 if it is a restart run. The objects to be processed are known already.
1300 – Edit Objects: The processing logic to be implemented using parallel processing for the selected objects is written in this method. This function module is used to implement the business logic and
Also, obiviously you would like to log your messages , so the framwrok provides macros to do it.
Let me know if you need some further help as I know there is very little information provided on this.
Regards/Ajay
Maybe you are looking for
-
How do I undo whatever went wrong after installing the latest update to Photoshop 2014 and suddenly when I tried to paint or touch up my illustration (book cover I'd drawn and painted, then scanned in and continued painting, changing. It's mostly don
-
Hi All, I am new to XSLT mapping. My requirement is: file to XML file with CDATA, for this I am planning to use the XSLT Mapping. I downloaded the Stylus studio, then what next, Please help meu2026 In source flat file I have 5 fileds, and target I ne
-
Screen flicker. Should I be worried?
I have a 2011 27" iMac. I looked around the forums and seems like, while there are some people with flickering issues, I have a different kind of flicker. At random times, the screen brightness on my iMac flickers from light-to dark. It's not one of
-
Name-value pairs in item editor
I am setting up a datagrid that must have in some fields an itemEditor displaying a combobox with name/value pairs: <mx:DataGrid height="100%" width="100%" id="dgTaxa" editable="true"> <mx:columns>
-
Linux AppBldr Error 7 Invoke Node
* LabVIEW 6.02 FDS Linux S/N G12X17332 * AppBldr 6 Linux S/N J12X64523 My SSP subscription on this software has expired. The products were installed on Linux Mandrake 8.2 using the provided National Instruments RPM method. A query of the rpm database