|
Which path variable, and where do you want to set it? Windows, Linux, Solaris? Please clarify your question. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
thanx for ur time....i have already done it.
|
|
|
|
|
Muzammil Saeed wrote: .i have already done it.
Well, maybe you could post your answer so others may benefit?txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Richard MacCutchan wrote: Well, maybe you could post your answer so others may benefit?
well guys...i did not check this post so i did not know that you wanted my Anser.....OK
Here...if you installed jdk on default location then most probably path for java compiler javac is C:\Program Files\Java\jdk1.6.0_18\bin.This is my path, you use your own.
1....right click the My Computer icon on desktop
2....click the Advanced tab
3....At left bottom, click Envirnoment Variables.
4....Down there, you will find System Variables.....click New.
5....Type variable name Path and variable value ....path mentioned above.click OK.
Thats all.....
what is this all about??.
when you use the command promt then you compile the program using javac...you must set the path first using set path command...now if there, you exit from command prompt, then each time you have to set this path if you use command prompt to compile you program. This method sets that path permanently.
Hope made you clear.
|
|
|
|
|
Hi,
I'm guessing you're referring to the JAVA_HOME environment variable, if you're running Windows XP you can set this permanently using the System Properties (right-click This Computer and select properties), then on the Advanced tab click the Environment Variables button.
Hope this helps,
Fredrik Bornander
|
|
|
|
|
|
You may need something like this[^]. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Hello Friends
I am creating a view in which I am creating a shape3d object with the help of geometryInfo Class(using verts,faces).After that I am adding each shape object to BranchGroup and that branchgroup to sceneBase.
Now the Problem is that If I am having Single object in my file then it is showing up in viewer but if file contains two object then only one object is showing up in viewer but all other info of second object is getting stored.
Give some IDeas.
Thanks
Yogesh Sikri
|
|
|
|
|
You need to check the way that you are reading the file. Either your code ignores all subsequent data after reading the first item or only keeps the last item read.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
The relationSpaceShips between the classes in this project is as follows:
(1) SpacePort has-many SpaceShip
(2) SpaceShip has-a Captain
(3) SpaceShip has-a Engine
(4) SpaceShip has-a RegistrationDate
(5) Impulse is-a Engine
(6) Warp is-a Engine
(7) SpaceShip has-many Crewman
(6) Person has-a pid (int)
(9) Person has-a DateOfBirth
(10) Captain is-a Officer
(11) Officer is-a Person
(12) DateOfBirth is-a StarDate
(13) RegistrationDate is-a StarDate
(14) StarDate has-a day (int)
(15) StarDate has-a month (int)
(16) StarDate has-a year (int)
(17) Enterprise is-a SpaceShip
(18) WarBird is-a SpaceShip
(19) RedShirt is-a Crewman
(20) Crewman is-a Person
NOTE:every object has:
private String objName, and
public String getName() {return objName;}
Create a test program that creates an SpacePort object, and prompts for
the user to enter the path of a data file. The program then reads the data from the data
file for the SpacePort.
Then, print:
1. all SpaceShip objects belonging to the SpacePort, sorted by getName(), and
2. all Person objects belonging to the SpacePort, sorted by getName()
Test your program by creating a data file and filling it in
with the data that answers the questions. Include the
data file and run.bat in the project folder.
Rules:
1. Each class above includes, in addition to the constructors:
public String toString(){
//return a string of the classname, the name, and toString() of all
parts.
}
public void readFromFile(){
//read the data from the user, including objName
}//readIn
2. The data members of each class MUST be declared "private" and you may not create
a public function that returns the value of any private data object, other than
getName() above.
3. All classes, except MainClass, should be in a package. Your project should have
at least 3 packages.
4. if you are reading in an element of class "C", where "C" is a superclass
of some other classes, then you must ask the user which of the subclasses
they want.
For example, suppose we have these relationSpaceShips:
Dealer has-many Car
Ford is-a Car
Honda is-a Car
then the readFromFile() function for Dealer might look like this:
Code:
public void readFromFile(FileIO fio) thows Exception{
if(fio.hasNextInt()==false){
throw new Exception("Dealer.readFromFile:missing ncars");
}
int ncars = fio.getNextInt();
carArray = new Car[ncars];
for(int i=0;i<carArray.length;i++){
if(fio.getNextLine()==false){
throw new Exception("Dealer.readFromFile:missing ncars");
}
String cartype=fio.getNextLine();
if(cartype.equals("f")){
carArray[i]= new Ford();
}else{
carArray[i]= new Honda();
}
carArray[i].readFromFile(fio);
}
}
You may assume that class fileioPkg.FileIO is part of your project:
package fileioPkg;
import java.util.*;
import java.io.*;
public class FileIO {
private FileReader freader;
private Scanner scan=null;
public FileIO(){
freader=null;
scan=null;
}
public FileIO(String filename) throws FileNotFoundException{
File infile;
FileReader reader;
infile = new File(filename);
reader = new FileReader(infile);
scan = new Scanner(reader);
}
public boolean hasNextInt() throws Exception{
if(scan==null){
throw new Exception("FileIO.getNextInt:file not opened");
}else{
return scan.hasNextInt();
}
}
public int getNextInt() throws Exception{
if(scan==null){
throw new Exception("FileIO.getNextInt:file not opened");
}else{
int iv=scan.nextInt();
System.out.println("FileIO.getNextInt:"+iv);
return iv;
}
}
public boolean hasNextLine() throws Exception{
if(scan==null){
throw new Exception("FileIO.getNextInt:file not opened");
}else{
return scan.hasNextLine();
}
}
public String getNextLine() throws Exception{
if(scan==null){
throw new Exception("FileIO.getNextInt:file not opened");
}else{
String result=scan.nextLine().trim();
System.out.println("FileIO.getNextLine:"+result);
return result;
}
}
public boolean hasNextDouble() throws Exception{
if(scan==null){
throw new Exception("FileIO.getNextInt:file not opened");
}else{
return scan.hasNextDouble();
}
}
public double getNextDouble() throws Exception{
if(scan==null){
throw new Exception("FileIO.getNextInt:file not opened");
}else{
double dv=scan.nextDouble();
System.out.println("FileIO.getNextDouble:"+dv);
return dv;
}
}
public void close(){
try {
freader.close();
} catch (IOException e) {
}
}
}
So far I created all the classes such as SpacePort, Crewman etc. I created the super classes for example SpaceShip extends SpacePort. I created a mainclass which asks the user to enter a txt file. But fromt his spot I am stuck on what I am so post to do. I have no idea how the txt file is supposed to look like and what the program is to do. Can someone please exaplin this to me in idiot proof terms. Sorry I am still new to java.
|
|
|
|
|
This seems like a rather advanced test program for someone who is new to Java. I suggest you take a look at The Java Tutorials[^] for help on reading and writing files. As to the format of your data file, you will need to decide that yourself, and will depend on what fields you need. For example suppose you need to get the name and age of a crewman, the line in the textfile could be:
CREW, Mr Spock, 750
Your program then needs to read this line and split the content into the correct fields so that you can create a Crewman object.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
JLayerPane - three problems
1 - I need fix row and column in layer pane and when mouse click it return my coordinates, not actual?
2 - I want to draw in this Layer, But could't?
3 - When i try AffineTransform, my coordinate origin does not moved?
If anybody have solution please reply........
class LayerPane extends JComponent
{
void LayerPane(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4,int recW,int recH)
{
JLayeredPane lp = new JLayeredPane();
f.setLayeredPane(lp);
GridLayout grid = new GridLayout(1600, 1440,recW,recH);
lp.setLayout(grid);
lp.setBounds(x1-5, y1-30, recW, recH);
lp.setLocation(x1-5,y1-30);
lp.setOpaque(true);
Color color = new Color(0, 0, 0, 0.4F);
lp.setBackground(color);
MyListenerLP myListener2 = new MyListenerLP();
lp.addMouseListener(myListener2);
lp.setVisible(true);
}
public void paintComponent(Graphics g)
{
g.setColor(Color.blue);
g.drawLine(x,y,x+50,y+50);
System.out.print("\nx,y is = "+x);
System.out.print(", "+y);
}
class MyListenerLP extends MouseInputAdapter
{
public void mouseClicked(MouseEvent e)
{
int x = e.getX();
int y = e.getY();
System.out.print("\nX,Y = "+x);
System.out.print(", "+y);
repaint(x,y,x,y);
}
}
}
|
|
|
|
|
Hi All,
I have a doubt.
I was just trying out some basic things in Core Java.
Here is the code
public class Test {
public static void main(String args[]) {
String a = "Hai";
String b = "Hai";
if(a == b) {
System.out.println("Equal");
} else {
System.out.println("Not Equal");
}
}
}
I Assumed that the result would be "Not Equal" as == does reference comparison. But I got the answer as "Equal".
Then I tried the second code
public class Test {
public static void main(String args[]) {
String a = "Hai";
a += "";
String b = "Hai";
if(a == b) {
System.out.println("Equal");
} else {
System.out.println("Not Equal");
}
}
}
Now i could get "Not equal". But logically both codes are same.
Why is this so?? Does Java share similar Objects??
Can anyone give an explanation on this??
Thanks,
Annns... modified on Thursday, February 11, 2010 8:38 AM
|
|
|
|
|
As you guess the objects are the same, as they both point to the exact same constant; this is the Java compiler optimising your code. Then when you add another character to a it becomes a new object and is no longer the same as b , even though, in human terms it has not changed.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
|
To add to Richards earlier answer, == checks that the objects are the same and equals(Object) should be overriden for ALL classes and checks that the contents are the same [this is the case with String ].
Try this to see:
public class TestEquals
{
public static void main(String args[])
{
String a = new String("Hai");
String b = new String("Hai");
if(a == b)
{
System.out.println("a == b true");
} else {
System.out.println("a == b false");
}
if(a.equals(b))
{
System.out.println("a.equals(b) true");
} else {
System.out.println("a.equals(b) false");
}
}
}
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
Nagy Vilmos wrote: // Make sure we have two DIFFERENT objects:
String a = new String("Hai");
String b = new String("Hai");
Thanx...You are right. We should make sure that we make two different objects. But I have a doubt in my mind....both a and b should refer to same objects if we write b = a...why they are refering to same object if we say a="Hai" and b="Hai"??
|
|
|
|
|
What I think you are asking is why, when we write...
String a="Hai";
String b="Hai";
...are a and b the same object and not just the same value?
When you use a literal string, there will only be one created unless you explicitly create a new instance. m Think of the literal as a constant referencing an object.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
Hi,
Am using a File upload tag in a JSP page.
(Input type="file")
After clicking submit(),after usual validation,sometimes user is getting error validation message.at this point of time, the content in the textbox is clearing and system is focusing the the textbox next to browse button.
Here am validatiing the page click with image comparision which is Serverside.
so is there anyway to hold the content(path)in the text box.Have a Nice Day Dudes
|
|
|
|
|
session variable or cookies.
|
|
|
|
|
This is not a Java question (JavaScript != Java), so you may get a better response in the ASP.NET or Web Development forum. Please read the guidelines[^] to make sure you post in the right place. MVP 2010 - are they mad?
|
|
|
|
|
Richard MacCutchan wrote: JavaScript != Java
yet you can use both together.
|
|
|
|
|
4277480 wrote: yet you can use both together.
You can use WPF with VB.NET or C#, but WPF is still not either of those languages.
However, my main point is that this question stands a better chance of an answer in a more appropriate place. I don't think many of the Web developers look at the Java forum.MVP 2010 - are they mad?
|
|
|
|
|
I know what you mean and your absolutely correct, I only wanted to mention it.
|
|
|
|
|
Can someone tell me how this can be done in Java? It's a PERL Web service call in Phyton, there is no WSDL available. Any suggestions will be appreciated.
server = SOAP.SOAPProxy("https://xyz:xyz@soap.abc.com/mod_soap",namespace="somenamespace")
test=('connection_test','')
a=apply(server.dynamic, test)
print a
|
|
|
|
|