Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 1 of 3 123 LastLast
Results 1 to 25 of 63

Thread: Writing Path name to configure Java

  1. #1
    Member
    Join Date
    Jun 2013
    Posts
    33
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Writing Path name to configure Java

    I have recently downloaded the Java Programming language onto my computer and have configured it successfully. However, when I was attempting another program, it required the use of the ptolemy.plot.* package. I did not realise that I needed to download this.

    I have done so, (downloaded the compressed zip file ptplot5.8 from the below site) however, I am unsure of where to place this in the path name.
    I have tried several different routes but whatever I try, I still get errors on the terminal. This makes me think there is a specific route that has to be followed.
    -link removed-

    If you require any more information, I can provide it.

    Many thanks.
    Last edited by jps; June 7th, 2013 at 06:19 PM. Reason: removed useless link


  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    585
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Writing Path name to configure Java

    The jar files you reference, have to be in the classpath. This is not a path issue.

  3. #3
    Member
    Join Date
    Jun 2013
    Posts
    33
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Writing Path name to configure Java

    Quote Originally Posted by PhHein View Post
    The jar files you reference, have to be in the classpath. This is not a path issue.
    Hi PhHein, could you give me an example of a typical class path? What I have is the following: \Program Files\Java\jdk1.7.0_21\bin. That's what I used to initially configure java. Should i make another classpath for Ptplot5.8 and/or where should I put this Ptplot5.8 file?

    Thanks.

  4. #4
    Member angstrem's Avatar
    Join Date
    Mar 2013
    Location
    Ukraine
    Posts
    200
    My Mood
    Happy
    Thanks
    9
    Thanked 31 Times in 29 Posts

    Default Re: Writing Path name to configure Java

    You have to add the path of all the included JARs to your classpath. You might find useful this tutorial.

  5. #5
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    585
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Writing Path name to configure Java

    And always keep in mind that path and classpath are two completely different things. Path is a system vartiable that tells your OS where to look for executables (java.exe etc.). Classpath is derfined at runtime and tells the compiler or VM where to look for java files (java, class, jar, etc.). Another link: How Classes are Found

  6. #6
    Member
    Join Date
    Jun 2013
    Posts
    33
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Writing Path name to configure Java

    Quote Originally Posted by PhHein View Post
    And always keep in mind that path and classpath are two completely different things. Path is a system vartiable that tells your OS where to look for executables (java.exe etc.). Classpath is derfined at runtime and tells the compiler or VM where to look for java files (java, class, jar, etc.). Another link: How Classes are Found
    What I have so far is java - classpath d:/tmp/ptplot5.8/ptolemy/plot/plot.jar. When I put this into the terminal, I get errors. I got this from one of the tutorials, however, I don't know what d:/tmp stands for, nor does the tutorial explain.

    Thanks.

  7. #7
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    585
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Writing Path name to configure Java

    Replace it with the path to the jar file in your file system. It's just an example.

  8. #8
    Member
    Join Date
    Jun 2013
    Posts
    33
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Writing Path name to configure Java

    Hi PhHein,
    Quote Originally Posted by PhHein View Post
    Replace it with the path to the jar file in your file system. It's just an example.
    That more or less is the same path - I think the problem is this /tmp. Do you know what that means and is it the error?

  9. #9
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    585
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Writing Path name to configure Java

    d:/tmp/ptplot5.8/ptolemy/plot/plot.jar is the path to the jar file in your file system. Drive d ,folder tmp, etc.

  10. #10
    Member
    Join Date
    Jun 2013
    Posts
    33
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Writing Path name to configure Java

    Quote Originally Posted by PhHein View Post
    d:/tmp/ptplot5.8/ptolemy/plot/plot.jar is the path to the jar file in your file system. Drive d ,folder tmp, etc.
    Hopefully that is the problem, I'll check later - thanks.

    --- Update ---

    Quote Originally Posted by PhHein View Post
    d:/tmp/ptplot5.8/ptolemy/plot/plot.jar is the path to the jar file in your file system. Drive d ,folder tmp, etc.
    So what I have is java -classpath C:\ProgramFiles\Java\jdk1.7.0_21\ptplot5.8\ptolemy \plot\plot.jar; and when compliling with the source: javac -classpath C:\ProgramFiles\Java\jdk1.7.0_21\ptplot5.8\plot\pl ot.jar; Edisc.java, where Edisc.java is the java file I want compiled. I still obtain the same error message that is ptolemy.plot package does not exist.

    I am wondering if I need to provide a classpath for the other jar files (i.e I also see plotapplication.jar) If so, and this would be the next thing I try, do I put these different jar files in the same classpath. If so, how? and if not, how do I create another command in the terminal so as to write this other classpath before compiling?

    Sorry if these are elementary questions: I am just starting out in JAVA and am installing the software onto my computer. I have done JAVA at my university, however, the problem I am having here is purely configuration (at the moment).

    Many thanks.

  11. #11
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    585
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Writing Path name to configure Java

    You can add all jars at once when compiling, separated by semicolon: javac -classpath .;path1/jar1.jar;path2/jar2.jar Edisc.java
    The . is the current directory, where your Edisc.java file is saved.

  12. #12
    Member
    Join Date
    Jun 2013
    Posts
    33
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Writing Path name to configure Java

    Quote Originally Posted by PhHein View Post
    You can add all jars at once when compiling, separated by semicolon: javac -classpath .;path1/jar1.jar;path2/jar2.jar Edisc.java
    The . is the current directory, where your Edisc.java file is saved.
    So I have javac -classpath .;C:\ProgramFiles\Java\jdk1.7.0_21\ptplot5.8\ptole my\plot\plot.jar;C:\ProgramFiles.......\plot\plota pplication.jar;C:\ProgramFiles\.....\plotapplet.ja r Edisc.java

    I still obtain the 'ptolemy.plot package does not exist' error. Is there anything else I could try? How do I know in advance what jar files to add to the classpath?

  13. #13
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    585
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Writing Path name to configure Java

    You have to add the jar that contains the package ptolemy.plot. It's in plot.jar.

  14. #14
    Member
    Join Date
    Jun 2013
    Posts
    33
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Writing Path name to configure Java

    Quote Originally Posted by PhHein View Post
    You have to add the jar that contains the package ptolemy.plot. It's in plot.jar.
    Something like javac -classpath .:C:\ProgramFilesJava\jdk1.7.0_21\ptplot5.8\ptolem y\plot\plot.jar ptolemy.plot?

  15. #15
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    585
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Writing Path name to configure Java

    javac -classpath .;C:/ProgramFilesJava/jdk1.7.0_21/ptplot5.8/ptolemy/plot/plot.jar Edisc.java

  16. #16
    Member
    Join Date
    Jun 2013
    Posts
    33
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Writing Path name to configure Java

    Quote Originally Posted by PhHein View Post
    javac -classpath .;C:/ProgramFilesJava/jdk1.7.0_21/ptplot5.8/ptolemy/plot/plot.jar Edisc.java
    Is that not what I tried in post #10?

  17. #17
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    585
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Writing Path name to configure Java

    Nope, it's not the same.

  18. #18
    Member
    Join Date
    Jun 2013
    Posts
    33
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Writing Path name to configure Java

    Quote Originally Posted by PhHein View Post
    Nope, it's not the same.
    I see - in post #10 I missed out \ptolemy\. That was just a typo. Is it not the same as in 12 then? (except I added on more jar files). When I enter what you wrote in 16, I still have this ptolemy.plot does not exist error.
    Thanks for your patience.

  19. #19
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    585
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Writing Path name to configure Java

    Ok, I've slapped together a test:
    package ph;
     
    import ptolemy.plot.*;
     
    public class PLTest{
    	public static void main(String[] args){
    		System.out.println("Jap");
    		Plot p = new Plot();
    		p.setName("phh");
    		System.out.println(p.getName());
    	}
    }
    Directories are:
    d:/test.1/plot.jar
    d:/test.2/ph/PLTest.java

    D:\test.2>javac -classpath .;d:/test.1/plot.jar ph/PLTest.java
     
    D:\test.2>java -cp .;d:/test.1/plot.jar ph/PLTest
    Jap
    phh
     
    D:\test.2>
    Compare that with what you have.

  20. #20
    Member
    Join Date
    Jun 2013
    Posts
    33
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Writing Path name to configure Java

    Here is my full source code:

    import java.io.Console;
    import java.io.*;
    import java.lang.Math;
    import java.lang.Boolean;
    import ptolemy.plot.*;
     
    public class Edisc {
    	public static void main (String args[]) {
     
    	Console.myConsole = System.console();
     
    	Plot disc = new Plot();
    	disc.setTitle("Graph of the axial E field from a charged disc");
    	disc.setXLabel("distance along z");
    	disc.setYLabel("E field");
     
    	PlotFrame myFrame = new PlotFrame("E vs z", disc);
    	myFrame.setSize(800,600);
     
    	int dataSet = 0;
     
    	double q = 6.0e-9;
    	double R  = 10;
    	double eps = 8.85e-12;
     
     
     
    	int points = 100;
     
    	double E[] = new double[points];
    	double z[] = new double[points];
     
    	for(int i = 0; i < (points-1); i++) {
    	z[i] = (100*(int)i/points); 
     
    	double Eqn = q*((2*(Math.PI())*eps*(Math.pow(R,2))))^(-1)*(1 - z[i]*((Math.sqrt((Math.pow(R,2)) + (Math.pow(z[i],2))))))^(-1);
     
    	disc.addPoint(dataSet, z[i], Eqn, true);
     
    	myFrame.setVisible(true);
    	}
     
    } 
     
    }

  21. #21
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    585
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Writing Path name to configure Java

    You should first get rid of all the ptolemy stuff and compile it without it. You'll already run into compilation errors then.

  22. #22
    Member
    Join Date
    Jun 2013
    Posts
    33
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Writing Path name to configure Java

    Quote Originally Posted by PhHein View Post
    You should first get rid of all the ptolemy stuff and compile it without it. You'll already run into compilation errors then.
    Do you mean there are errors in the code?

  23. #23
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    585
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Writing Path name to configure Java

    Yes.

  24. #24
    Member
    Join Date
    Jun 2013
    Posts
    33
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Writing Path name to configure Java

    Quote Originally Posted by PhHein View Post
    Yes.
    All the errors that appeared were to do with this apparent non existence of the ptolemy.plot (there were 7 errors in total). Where are the other errors and why does the compiler not pick them up?

  25. #25
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    585
    My Mood
    Sleepy
    Thanks
    10
    Thanked 87 Times in 80 Posts

    Default Re: Writing Path name to configure Java

    Because there's an order what the compiler checks. First all required dependencies are checked, and if those are ok, the actual code is compiled. In this case the compiler didn't get to that point.

Page 1 of 3 123 LastLast

Similar Threads

  1. How to configure context.xml in netbeans IDE?
    By tangara in forum Java IDEs
    Replies: 1
    Last Post: January 5th, 2012, 10:18 PM
  2. How to convert local path drive to UNC path
    By krisswift in forum Object Oriented Programming
    Replies: 2
    Last Post: November 17th, 2011, 07:40 AM
  3. Relative path issue with Context path struts
    By chinnu in forum Web Frameworks
    Replies: 1
    Last Post: March 31st, 2011, 10:17 AM
  4. TOMCAT CONFIGURE
    By jugalrockz in forum Java Servlet
    Replies: 1
    Last Post: January 5th, 2011, 06:09 PM
  5. how to get full path name from realtive path
    By priyanka3006 in forum File I/O & Other I/O Streams
    Replies: 8
    Last Post: August 10th, 2009, 04:28 AM