| | |
Frequently Used Classes
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2008
Posts: 1,657
Reputation:
Solved Threads: 206
0
#2 Oct 18th, 2009
You can use a package that includes all of your essential classes and just import that package into any class where you want to use those classes. So basically, if you wanted to import the popular File class, you would use import java.io.File; but if you wanted to import the whole package you could say import java.io.*;
Out.
1
#3 Oct 19th, 2009
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Sep 2009
Posts: 28
Reputation:
Solved Threads: 0
0
#5 Oct 20th, 2009
I've tried but failed to create a file of common classes that I can import! Here's what I did.
I'm using NetBeans 6.7.1 as my IDE.
1) I created standard Project:
File -> Java:Java Application -> Project Name: common.Code. I Left Create Main Class and Set as Main Project both checked. This created a package named "commoncode" with a main class of CommonCode.
2) I then added a file containing one of the classes I want use as common code.
3) I did a Clean and Build project.
4) In the output, the path for the jar was was listed. I copied the absolute path,including the jar file name, to my CLASSPATH.
5) I restarted NetBeans.
6) I then tried all these imports. None worked.
import common.Code.*;
import CommonCode.*;
import commoncode.*;
So, my friends, what am I doing wrong?
Thanks you very much for your help.
I'm using NetBeans 6.7.1 as my IDE.
1) I created standard Project:
File -> Java:Java Application -> Project Name: common.Code. I Left Create Main Class and Set as Main Project both checked. This created a package named "commoncode" with a main class of CommonCode.
2) I then added a file containing one of the classes I want use as common code.
3) I did a Clean and Build project.
4) In the output, the path for the jar was was listed. I copied the absolute path,including the jar file name, to my CLASSPATH.
5) I restarted NetBeans.
6) I then tried all these imports. None worked.
import common.Code.*;
import CommonCode.*;
import commoncode.*;
So, my friends, what am I doing wrong?
Thanks you very much for your help.
Last edited by bruceaj; Oct 20th, 2009 at 4:06 pm. Reason: technical errors
•
•
Join Date: Sep 2009
Posts: 28
Reputation:
Solved Threads: 0
0
#7 Oct 20th, 2009
Thanks. Adding it to the project classpath worked. The thing I don't like is that it looks like I have to manually add it to the classpath of each project I build. How can I have it added automatically?
Also, can I remove it from my System Classpath?
Also, can I remove it from my System Classpath?
Last edited by bruceaj; Oct 20th, 2009 at 6:11 pm.
•
•
Join Date: Nov 2008
Posts: 332
Reputation:
Solved Threads: 54
0
#8 Oct 20th, 2009
Modify build.xml file, look at files inside nbproject folder.
go to http://www.netbeans.org/ for info.
go to http://www.netbeans.org/ for info.
![]() |
Similar Threads
- Classes and Linked Nodes (C++)
- Class Interface (C#)
- How do i do chat program using MFC (Microsoft Foundation Classes) and Visual Basic? (Visual Basic 4 / 5 / 6)
- Working with objects of different Classes (Java)
- svchost.exe error (Windows NT / 2000 / XP)
- Classes (C++)
- Summer Classes (Geeks' Lounge)
Other Threads in the Java Forum
- Previous Thread: Have you ever felt this dumb? (It's SO not fun.)
- Next Thread: Linked List program - stumped w/ 1 problem
Views: 311 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for Java
3d @param affinetransform android api apple applet application arc arguments array arrays automation binary bluetooth byte c# chat class classes click client code color compare component corrupted database detection draw eclipse error event exception file fractal game givemetehcodez graphics gui guitesting helpwithhomework html ide image input integer j2me java java.xls javaprojects jmf jni jpanel julia keytool keyword linux list loop map method methods mobile netbeans newbie number object oracle pong print problem producer program programming project projectideas read recursion reflection rim scanner screen server set size sms socket sort sql string swing terminal test threads time transfer tree web windows






