Importing custom classes
I created a java class that I want to put in a universal folder and be made accessible to all java programs on my computer. I tried using CLASSPATH so that files I make can locate it, but it didn't work, and I don't know if I can use an import statement or not. Does anyone know how I can have a custom-made class (located in, for example, C:/classes/) be accessible to all java programs?
I want to be able to put the universally accessible class in a root directory (like C:/classes/), so using packages wouldn't work that well since other java classes would be much further in (C:/users/.../documents/java/...).
The way I tried to set up my classpath is I set CLASSPATH=C:/bin/. bin is the directory where I keep my compiled class files (javac -d C:/bin/ MyClass.java), which would also include the .class file of the one I want accessible. I can run any java file in bin (java -cp C:/bin/ MyClass), but when it searches for external files it still searches in the directory in which it's located.
Similar Messages
-
How to import custom classes from model to view controller in adf?
hi...
i have some custom classes in model layer in adf.
i want to use them in view controller but i cannot import them.
how is this possible?
my jdev version is 11.1.1.5You normally don't have to do anything special. The view controller project has a dependency to the model project. So simply typing the class name should show you hte option to generate the need import statement for the class.
However, not all classes which reside in the model project should be imported into the view Controller as it might break the MVC pattern.
Timo -
Trouble importing custom class
Hi all
Just working my way through Programming for Mac OS X (2nd edition), and I've gotten all stuck at page 62. We've just created a custom class, and then try and 'build & go' the application. However, it never compiles, it always complain with my command to "#import <LotteryEntry.h>" that "error. LotteryEntry.h no such file or directory".
I'm all confused why because there IS such a file! Lol.
Any help would be appreciated
AdamI stumbled on the same error. Be sure to use *import "LotteryEntry.h"* and not *import <LotteryEntry.h>* as suggested by the automatic completion of XCode.
-
'Cannot Resolve Symbol' error when importing custom class
I get this error...
c:\mydocu~1\n307\auto.java:14: cannot resolve symbol
symbol: class Box
import Box;
^
when I try to compile auto.java, the applet that's supposed to import the class Box, which I built to be like a message box in VB. Here is the code for Box...
import java.awt.*;
import java.awt.event.*;
public class Box extends Window{
Label lblMsg = new Label();
Button cmdOk = new Button("OK");
Panel pnlSouth = new Panel();
EventHandler ehdlr=new EventHandler(this);
public Box(Frame parent){
super(parent);
setLayout(new BorderLayout());
add(lblMsg, BorderLayout.NORTH);
add(pnlSouth, BorderLayout.SOUTH);
pnlSouth.setLayout(new FlowLayout());
pnlSouth.add(cmdOk);
cmdOk.addActionListener(ehdlr);
this.addWindowListener(ehdlr);
public void speak(String msg){
lblMsg.setText(msg);
this.setLocation(200,200);
this.setSize(200,200);
this.setVisible(true);
private class EventHandler extends WindowAdapter
implements ActionListener{
Window theWindow;
public EventHandler(Window a){
theWindow=a;
public void actionPerformed(ActionEvent e){
theWindow.setVisible(false);
AND HERE IS THE CODE FOR AUTO...
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
import Box;
public class auto extends Applet implements ActionListener{
Panel pnlCenter=new Panel();
Panel pnlSouth=new Panel();
Panel pnlNorth=new Panel();
Panel pnlCenterleft=new Panel();
Panel pnlCenterright=new Panel();
Button cmdSubmit=new Button("Submit");
Button cmdNext=new Button("Next");
Button cmdPrev=new Button("Previous");
Label lblLoc=new Label("LOCATION:");
Label lblDate=new Label("DATE:");
Label lblMile=new Label("MILEAGE:");
Label lblCost=new Label("COST:");
Label lblDesc=new Label("DESCRIPTION:");
Label lblFind=new Label("FIND LOCATION:");
Label lblDisp=new Label();
TextField txtLoc=new TextField();
TextField txtDate=new TextField();
TextField txtMile=new TextField();
TextField txtCost=new TextField();
TextArea txtDesc=new TextArea();
TextField txtFind=new TextField();
Box bxOne = new Box((Frame(this).getParent()));
/*by declaring these four variables here, they are instance level, meaning they are
available to the whole applet*/
String textFile="auto.txt";
String list[] = new String[100];
String sort[] = new String[100];
int counter=0;
int count=0;
String currentLine="";
int i;
int sortcount;
public void init(){
this.setLayout(new BorderLayout());
this.add(pnlNorth, BorderLayout.NORTH);
this.add(pnlCenter, BorderLayout.CENTER);
this.add(pnlSouth, BorderLayout.SOUTH);
pnlNorth.setLayout(new FlowLayout());
pnlNorth.add(new Label("VIEW RECORDS"));
pnlCenter.setLayout(new GridLayout(1,2));
pnlCenter.add(pnlCenterleft);
pnlCenter.add(pnlCenterright);
pnlCenterleft.setLayout(new GridLayout(0,1));
pnlCenterleft.add(lblLoc);
pnlCenterleft.add(lblDate);
pnlCenterleft.add(lblMile);
pnlCenterleft.add(lblCost);
pnlCenterleft.add(lblDesc);
pnlCenterleft.add(lblFind);
pnlCenterright.setLayout(new GridLayout(0,1));
pnlCenterright.add(txtLoc);
pnlCenterright.add(txtDate);
pnlCenterright.add(txtMile);
pnlCenterright.add(txtCost);
pnlCenterright.add(txtDesc);
pnlCenterright.add(txtFind);
pnlSouth.setLayout(new FlowLayout());
pnlSouth.add(cmdPrev);
pnlSouth.add(lblDisp);
pnlSouth.add(cmdSubmit);
pnlSouth.add(cmdNext);
lblDisp.setText("0 of 0");
cmdPrev.addActionListener(this);
cmdNext.addActionListener(this);
cmdSubmit.addActionListener(this);
public void actionPerformed(ActionEvent e){
String command=e.getActionCommand();
if (command.equals("Next")){
if(txtLoc.getText().equals("")){
reader();
transfer();
writer();
bxOne.speak("Viewing all records");
}else{
if(counter<count-2){
counter++;
writer();
}else{
//don't move
} else if (command.equals("Previous")){
if(txtLoc.getText().equals("")){
//do nothing
}else{
if(counter>0){
counter--;
writer();
}else{
//don't move
} else {
txtLoc.setText("");
txtDate.setText("");
txtMile.setText("");
txtCost.setText("");
txtDesc.setText("");
reader();
sorter();
writer();
private void writer(){
StringTokenizer stCurrent=new StringTokenizer(sort[counter], "\t");
txtLoc.setText(stCurrent.nextToken());
txtDate.setText(stCurrent.nextToken());
txtMile.setText(stCurrent.nextToken());
txtCost.setText(stCurrent.nextToken());
txtDesc.setText(stCurrent.nextToken());
lblDisp.setText(String.valueOf(counter+1) + " of " + String.valueOf(count-1));
private void reader(){
try{
URL textURL=new URL(getDocumentBase(), textFile);
InputStream issIn=textURL.openStream();
InputStreamReader isrIn=new InputStreamReader(issIn);
BufferedReader brIn=new BufferedReader(isrIn);
while(currentLine!=null){
currentLine=brIn.readLine();
list[count]=currentLine;
count++;
}catch(MalformedURLException exc){
System.out.println("MalformedURLException Error");
}catch(IOException exc){
System.out.println("IOException Error");
}catch(NullPointerException exc){
System.out.println("NullPointerException Error");
private void transfer(){
for(i=0;i<count;i++){
sort=list[i];
private void sorter(){
sortcount=0;
String find=txtFind.getText();
System.out.println(String.valueOf(count));
for(i=0;i<count-1;i++){
StringTokenizer st=new StringTokenizer(list[i], "\t");
String next=st.nextToken();
if (find.equals(next)){
sort[sortcount]=list[i];
sortcount++;
count=sortcount+1;
Any help is greatly appreciated.
2Willis4Hi agian,
I looked closer at your code, I think if you play around with directories and paths, you'll get it, and I think also when you import, you have to have put the class in a package...? Maybe? Blind leading the blind here! So at the top of your box class you have to say something like
package org.blah.lala
and you have to have that directory structure for the class files org/blah/lala/Box.class
Does that make sense?
And then when you import you say:
import org.blah.lala.Box
(I think)
I cna only imagine that this 'help' I am giving you would be hilarious to a more experienced programmer!
Anyway, best of luck. -
Importing Custom Classes into a JSP page
Hello,
I have created custom package com.srjgroup.report. It sits in C:\workspace\src\com\srjgroup\report directory. I have java files as well as compiled classes there. No jar files there.
did amend classpath to point to this directory.
In my JSP page I have the import statement as following
import="java.sql.*, java.util.*, java.text.SimpleDateFormat, com.srjgroup.report.*"It imports all the packages without any errors. However, when I try to use one of the classes in the package, I get error
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 3 in the jsp file: /SQLServer.jsp
Generated servlet error:
SRJReports cannot be resolved to a type
SRJReports is one of the classes that I am trying to use in that package. When I comment out all references to the class, everything is fine.
So, to fix this I moved the entire package to
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\lib direcory, preserving the hierarhy. So, now my custom package is located here:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\lib\com\srjgroup\report again there are no jar files, only java and classes here. Still, no go.
What am I doing wrong ?Put the class in
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\classes\com\srjgroup\report
One more thing, there is no subdirectory in lib directory. You may look at the example within tomcat for reference. I start from there. -
Can't import custom class!
I have no idea why as3 is so stupid but it is and I have to
deal with it. Basically, I creatd a Server.as file with the Server
class but I can't import it into my .fla! Both are in the same
folder and when I change properties to use AS2 it works! But when
I'm doing it in as3 it doesn't work...you don't need to use a directory structure for your files'
location, but you need to use the package designation in your class
definitions.
for example, if your Server class file is in the same
directory with your fla, you can use: -
How to import custom java jar/class into oracle to be used in java proc ?
Hi
I would like to know how to import custom java jar/class files into oracle to be used in java stored procedure.
I am developing a oracle pl/sql procedure to call java program. The java program will be created as procedure and will be published.
But, my question is that I do have a other external jar/class file that need to be imported into this java program.
example
raise_sal.java
import java.util.*;
import oracle.sql.*;
<<reference other java programs >>
import cmpmsgsvc.xxxx.* ;
import cmpmsgsvc.yyyy.* ;
import cmpmsgsvc.zzzz.* ;
how do I import the cmpmsgsvc jar/class file into oracle so that I don't have any
compilation errros on raise_sal.java program ??
what are the steps to import/compile and validate to do this?
thanks for your help in advance.
Thanks
rrb.Kuassi
Problem is that, I have 6 jar files that are needed to be included in the main java program. And, there are more than 50+ classes, propertiers in those 6 jar files.
It might be not good idea to have all those 50+ classes in the production database.
Is there anyway that I keep all those 6 jar files in unix box (our's is oracle erp installation with oracle being installed on unix box) and just refer them in the main java program. I mean database will be loaded with main java program and it should able to refer other 6 jar files from unix.
if we create a directory and keep all jar files in there and include that directory in classpath variable, does this works? or what is other method?
Please let me know.
Thanks -
Hi everyone...
I'm working on one final part of a Flash piece that's ended being quite a bear for me. So looking forward to wrapping it up! I'm a big-time newbie. This has been an amazing learning experience but boy it has made my brain hurt!
The final issue I'm having invloves importing a custom class that calls a custom application. It's a class/application that I downloaded and am trying to apply to my project. It is an application that adds transform handles around targeted objects.
I'm importing the class as I think I am supposed to but it doesn't work. There aren't any erros but it simply doesn't work.
Here's how I'm doing it...
My .FLA, FloorPlan.FLA, is located in my root folder along with the class file, ApplicationMain.as.
ApplicationMain.as has an import that imports the application called TransformTool.as. TransformTool.as is located in the root as well.
So in scenen 1 on frame 1 of FloorPlan.FLA I have an import written like so...
import ApplicationMain;
In the file ApplicationMain.as I have an import to grab the file TransformTool.as that is written like so...
package {
import flash.display.MovieClip;
import flash.geom.Rectangle;
import flash.events.MouseEvent;
import TransformTool;
public class ApplicationMain extends MovieClip
private var _transformTool;
public function ApplicationMain ()
_transformTool = new TransformTool();
_transformTool.mode = TransformTool.ROTATE;
_transformTool.iconScale = new HandleHintScale();
_transformTool.iconRotate = new HandleHintRotate();
// _transformTool.boundaries = new Rectangle(50, 50, 475, 260);
addChild(_transformTool);
// register targets //
_transformTool.targets = [content_MC.e1, content_MC.e2, content_MC.e3, content_MC.e4, content_MC.f1, content_MC.f2, content_MC.f3, content_MC.f4, content_MC.f5, content_MC.f6, content_MC.f7, content_MC.f8];
_transformTool.activeTarget = content_MC.f8;
// register radio buttons //
// radio1.addEventListener(MouseEvent.CLICK, changeToolMode);
// radio2.addEventListener(MouseEvent.CLICK, changeToolMode);
private function changeToolMode(evt:MouseEvent):void
_transformTool.mode = evt.currentTarget.label.toLowerCase();
Everything but this class/application is working just fine. It doesn't cause any erros and make other items not function. It simply isn't working. And I had it working at the very beginning of the project so I know its not the class/application files causing the problem; other than possible path issues.
I'm stumped, yet again!
Thanks in advance for your help!HandleHintScale and HandleHintRotate are movie clips in the library of the .fla
-
Importing a custom class error
In my testDB.jsp as follows,
<body>
<%@ page language="java" import="java.sql.*" %>
<%@ page import="DBConn" %>
<%
DBConn DBConn1 = new DBConn();
out.print("bean test:" + DBConn1.test_bean());
%>
</body >
</html >
I imported a custom class DBConn
DBConn.java
import java.sql.*;
public class DBConn
public DBConn()
public static int test_bean()
return 1;
Running on AS side. Encountered an error:
Request URI:/gis/class/testDB.jsp
Exception:
java.lang.NoSuchMethodError: DBConn: method test_bean()I not found
at gis.class._testDB._jspService(_testDB.java:63)
at oracle.jsp.runtime.HttpJsp.service(Compiled Code)
at oracle.jsp.app.JspApplication.dispatchRequest(Compiled Code)
at oracle.jsp.JspServlet.doDispatch(Compiled Code)
at oracle.jsp.JspServlet.internalService(Compiled Code)
at oracle.jsp.JspServlet.service(Compiled Code)
at javax.servlet.http.HttpServlet.service(Compiled Code)
at org.apache.jserv.JServConnection.processRequest(Compiled Code)
at org.apache.jserv.JServConnection.run(Compiled Code)
at java.lang.Thread.run(Compiled Code
Knowing that DBConn.class was included in the CLASSPATH
Thanks for any advice!HandleHintScale and HandleHintRotate are movie clips in the library of the .fla
-
Import of custom class doesn't seem to work...
OK, I have my custom class defined in a file called "rootInstace.as". This is what it contains:
package
import flash.display.MovieClip;
public class CRoot extends MovieClip
public static var _root:MovieClip;
public function CRoot ()
_root = this;
this file is located at C:\Flash_Files\rootStuff\.
I have this directory included in my Flash Edit\Preferences\ActionScript 3.0 Languages\Source Path for Source files. The path I gave it was C:\Flash_Files\
when I try to use the CRoot class in the first frame of my main .fla like this:
import rootStuff.*;
var rt:CRoot = new CRoot();
, it throws errors:
1046: Type was not found or was not a compile-time constant: CRoot.
1180: Call to a possibly undefined method CRoot.
what, I ask you, am I doing wrong?!Thank you. I also had to add a package name to reflect its location, but that was simple as well and I managed to figure it out.
-
Hi,
I am playing with WL6.0SP2. I started the exampleServer and can render the
HelloWorld.jsp page using
http://localhost:7001/examplesWebApp/HelloWorld.jsp. I added a line in
HelloWorld.jsp like <@ page import="com.xxx.common.*" %> and put the
exploded com.xxx.common classes under
\config\examples\applications\examplesWebApp\WEB-INF\calsses directory.
However, Weblogic failed to compile HelloWorld.jsp, complaining
com.xxx.common package can not be found. Where should I put the custom
classes do that it can be found by WL?
Thanks,
Shannon.
Hi,
I am playing with WL6.0SP2. I started the exampleServer and can render the
HelloWorld.jsp page using
http://localhost:7001/examplesWebApp/HelloWorld.jsp. I added a line in
HelloWorld.jsp like <@ page import="com.xxx.common.*" %> and put the
exploded com.xxx.common classes under
\config\examples\applications\examplesWebApp\WEB-INF\calsses directory.
However, Weblogic failed to compile HelloWorld.jsp, complaining
com.xxx.common package can not be found. Where should I put the custom
classes do that it can be found by WL?
Thanks,
Shannon.
-
Importing Custom folder/item class gives warning
Hi
When i trying to import custom folder in admin it gives me warning indicating that imported successfully but not in Business areas. now it shows in folder list but not in associated BA. so i have to manually assigned it to BA by selecting manage folders. Same thing happened with item class. it imported successfully but selected item was missing and it shows LOV in item class but when i select edit item class and i saw that selected item was empty.
Is it bug?
Plz help me.
Thanks,
JayHi Jay
I really do understand and again I sympathize. Let me state the correct approach and you will see how your organozation is deviating from what other companies do.
Most organizations that I work with have a single production environment. Under that they have a pre-production or QA environment, with further environments for development, test and training. They would never attempt to migrate to production without going through QA first, knowing also that QA was a copy of production that was refreshed not so long ago.
There would also be only one development environment and one test environment. It is not a good idea to have developers working on their own private EUL as this WILL cause issues during migration.
There's nothing to stop two developers working inside the same development EUL providing they are in different business areas. Its not wise to attempt multiple edits to the same business area at the same time as this makes for extremely difficult user testing.
Now, if you do decide to continue using multiple development EULs you must not migrate from these straight into production. You must migrate into the QA area first where you can test and make sure that no upset has occurred. Whenever something goes to production from QA it is imperative that those same changes be propogated to all of the other EUL instances otherwise you are asking for trouble.
Does any of this help?
Best wishes
Michael -
Importing Class to Custom Class
I'm writing my own class. (The Peacock class if you want to
know.) I want to use the Tween class in my class, but I don't know
how to import another class into my class. How do I go about that.
Thanks.It makes a fan of peacock feathers. It is mostly just an
excuse to practice my AS2. (David "Seething Cauldron" Still has
lured me to the dark side!) I've got the strut() and modesty()
methods down. I'm closing in on shimmy(). But there are two bits I
haven't really worked out yet, neither really has to do with AS 2.
Any good approach for having slight variations in color? I'm
using the drawing API to draw the spots/eyes and want to have each
one vary a bit in color. Any good approaches or places I should
check out?
The other is that crazy modulo math. I need to generate the
following sequence:
-1, 1, -2, 2, -3, 3, -4, etc.
and or alternately:
0, 1, 1, 0, 0, 1, 1, 0, 0, repeating
I've got a nasty hacky bit, but I'm sure there is an elegant
way, but my mind just doesn't go that way.
When I get it polished up a bit more I would be happy to post
a copy if you want to see it. -
Cannot import custom made java class
Hello
I wrote a java class say (Money.java) which compiled fine. When I was importing it to another class (Account.java), the folowing error message appears:
Account.java.1:'.' expected
import Money;(an errow pointing to ";")
I dont think the code is wrong, because when I cut and attach the Money class code to the front of the Account class it compiled successfully.... I am confused! I wrote the import command according to the text book as follows:
import Money;
public class Account
By the way, both the Money and Account classes are saved in the save folder... How come it wont let me import...
Looking forward for an early reply.
ThanksIn older versions of Java, it was possible to import classes from the default package using a statement like:
import Money;
This feature has been removed from Java as of version 1.5. You cannot import classes from the default package.
Note that if your other code (Account.java) is also in the default package, you do not need to import the class Money. Just remove the import statement.
If class Account is in a different package and you want to use class Money, then the only option you have is to put class Money in another package than the default (unnamed) package. -
Need help calling and looping custom classes
Hi, I am writing a code with custom classes in it and another program that calls upon all of the classes in the first program. I can get the second one (L6) to call upon and execute all of the classes of the first (Foreign). However, I need the second one to loop until quit is selected from the menu on Foreign and I can't seem to figure out how to do it. Here are the codes:
L6:
public class lab6
public static void main(String[] args)
Foreign camount = new Foreign();
camount = new Foreign();
camount.get();
camount.print();
camount.intake();
camount.convert();
camount.vertprint();
System.out.println(camount);
Foreign:
import java.util.Scanner;
public class Foreign
private String country;
private int choice;
private float dollars;
private float conversionValue;
private float conversionAmount;
public Foreign()
country = "null";
choice = 0;
dollars = 0;
conversionValue = 0;
conversionAmount = 0;
public void get()
Scanner Keyboard = new Scanner(System.in);
System.out.println("Foreign Exchange\n\n");
System.out.println("1 = U.S. to Canada");
System.out.println("2 = U.S. to Mexico");
System.out.println("3 = U.S. to Japan");
System.out.println("4 = U.S. to Euro");
System.out.println("0 = Quit");
System.out.print("\nEnter your choice: ");
choice = Keyboard.nextInt();
public void print()
System.out.print("\nYou chose " + choice);
public void intake()
Scanner Keyboard = new Scanner(System.in);
if (choice >= 1 && choice <= 4)
switch (choice)
case 1: System.out.println("\nU.S. to Canada");
conversionValue = 1.1225f;
country = ("Canadian Dollars");
break;
case 2: System.out.println("\nU.S. to Mexico");
conversionValue = 10.9685f;
country = ("Mexican Pesos");
break;
case 3: System.out.println("\nU.S. to Japan");
conversionValue = 118.47f;
country = ("Japanese Yen");
break;
case 4: System.out.println("\nU.S. to Euro");
conversionValue = 0.736377f;
country = ("European Union Euros");
break;
System.out.print("\nEnter U.S. dollar amount: ");
dollars = Keyboard.nextFloat();
public void convert()
conversionAmount = conversionValue * dollars;
public void vertprint()
System.out.println("\nCountry = " + country);
System.out.println("Rate = " + conversionValue);
System.out.println("Dollars = " + dollars);
System.out.println("Value = " + conversionAmount);
public String toString()
String line;
line = "\n" + country + " " + conversionValue + " " + dollars + " " + conversionAmount;
return line;
I appreciate any help anyone can give me. This is driving me crazy. Thanks.1. first you need to write method to get choice value from Foreign class.
simply add this method.
public class Foreign {
// ... Add this
public int getChoice() {
return choice;
}2. Then in your main, you can obtain with previos method.
public static void main(String[] args) {
Foreign camount = new Foreign();
// remove this. you alredy create an instance in last statement.
//camount = new Foreign();
int choice = 0;
do {
camount.get();
choice = camount.getChoice();
// your process...
} while (choice != 0);
}
Maybe you are looking for
-
How to make a new line item appear in a sales order in VA01 transaction?
Dear All, I am trying to create a SO with single line item with quantity 100. Upon hitting the 'Enter' key, if the available quantity is less than the requested quantity (say 20), it takes me to an availabilty control screen which has a push-button '
-
Is it possible to change the color of the regions in GB 11?
Is it possible to change the color of the regions in GB 11?
-
appletv not updating podcasts - has apple sold a product then dropped support after 1 yera? May 2014 - None of the podcasts are being updated on appletv. Running itunes 11.2 and it shows podcasts there. Apple looks more like windows every day.
-
Regional Settings list gone!
Hello everybody. I got the new iPhone 3G and followed the classic steps to get it to work. (I already have a 1st-gen iPhone, so everything went smoothly) Then it was time for me to set it up. I went to Settings > General > International > Region Form
-
Hi all, I purchased my MP3 player around and a half years ago. Recently, I had been having trouble with the MP3 player reconising music. It stated that there were less songs than there actually were on there. I had reformated, cleaned up, and most th