Author |
Message |
peanut
|
Posted: Fri Apr 14, 2006 8:45 am Post subject: Java on mac |
|
|
Hey guys, I'm doing some classes of Java programming in my university. And I work on a mac at home. From the university I got a element package with some classes that I need to use from my programming. I'm using right now xcode for mac, and well my question is how do I import the classes? I tried javac -classpath <path> but it doesnt seems to work.
Thx |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
wtd
|
Posted: Fri Apr 14, 2006 11:52 am Post subject: (No subject) |
|
|
Can you place the classes in the existing classpath (as specified by the CLASSPATH variable that I'm assumign exists)? |
|
|
|
|
![](images/spacer.gif) |
peanut
|
Posted: Fri Apr 14, 2006 12:51 pm Post subject: (No subject) |
|
|
well I must say that I'm totally new with computer language. Java is actually my first computer language that I'm learning. I read that I can put the element that I'm trying to load in each file, or load it in my classpath. However don't know what's my classpath. |
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: Fri Apr 14, 2006 1:53 pm Post subject: (No subject) |
|
|
Your classpath is where Java looks for classes.
Let's say I have a Java source file Test.java in my home folder (~):
code: | public class Test {
public static void main(String[] args) {
Foo f = new Foo();
}
} |
Now, I have Foo.java in ~/projects/java/
code: | public class Foo { } |
When I compile Test.java from the commandline...
code: | ~ $ javac -classpath projects/java Test.java |
And then to run it:
code: | ~$ java -classpath .;projects/java Test |
|
|
|
|
|
![](images/spacer.gif) |
peanut
|
Posted: Fri Apr 14, 2006 2:29 pm Post subject: (No subject) |
|
|
Yes I understand that, I don't use the terminal though to compile or execute the program. I'm using xcode, and well my question was more for the import of classes.
Example:
code: |
import element.*;
public class Assignment1
{
public static void main (String args[])
{
ConsoleWindow = new ConsoleWindow();
System.out.println("ConsoleWindow");
}
}
|
And the ConsoleWindow class has been put in the element package that I got from school (element.jar). Now I don't know how to import this file. |
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: Fri Apr 14, 2006 2:33 pm Post subject: (No subject) |
|
|
For simple projects, you will likely find the command-line a simpler working environment than Xcode (or most other IDEs). |
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: Fri Apr 14, 2006 2:36 pm Post subject: (No subject) |
|
|
As for using a JAR archive "element.jar" with classpath:
code: | javac -classpath /path/to/element MyClass.java |
Hopefully I'm remembering that correctly. |
|
|
|
|
![](images/spacer.gif) |
rizzix
|
Posted: Fri Apr 14, 2006 4:24 pm Post subject: (No subject) |
|
|
Or simply drop the jar in /Library/Java/Extensions |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
peanut
|
Posted: Sat Apr 15, 2006 6:45 am Post subject: (No subject) |
|
|
Thank you guys! I got it working. |
|
|
|
|
![](images/spacer.gif) |
Justin_
|
Posted: Sat Apr 15, 2006 7:04 pm Post subject: (No subject) |
|
|
So you have no previous experience with programming and you're taking it in university? Is computer science your major? I'm not trying to sound pejorative, but it seems ridiculous that somebody would study CS in university and not have a background in the subject. I mean, who pays money to learn about something they aren't familiar with? Won't it be a waste of money if you find out you don't like it? |
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: Sat Apr 15, 2006 7:17 pm Post subject: (No subject) |
|
|
One goes to a university to learn what's available. The vast majority of students will change their major at least once. A good portion of those will change majors three or more times. |
|
|
|
|
![](images/spacer.gif) |
peanut
|
Posted: Sun Apr 16, 2006 10:11 am Post subject: (No subject) |
|
|
Actually I'm studying Aerospace Engineering. And a subject that I get is JAVA programming. Somehow (in the near future), I'm going to use then my skills, that I'm learning now with JAVA, to program some things. What I know, is that next year I will be programing a flight simulator as a project . |
|
|
|
|
![](images/spacer.gif) |
md
![](http://compsci.ca/v3/uploads/user_avatars/1849317514ed6c4399768d.png)
|
Posted: Sun Apr 16, 2006 9:21 pm Post subject: (No subject) |
|
|
I know a whole lot more about CS then many people here; and yet I've decided to switch out of CS. Clearly what you study has little to do with what you know and more to do with what interests you. I know lots of people who knew very little or nothing about programming who are in CS now, and many people who knew lots about CS who are no longer in it after a year or two of it at university. |
|
|
|
|
![](images/spacer.gif) |
peanut
|
Posted: Sun Apr 16, 2006 10:18 pm Post subject: (No subject) |
|
|
lol, well yes, I am really interested in Java atm and I'm going to learn it on my free time, even if, at my university, we only learn the basics. |
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: Mon Apr 17, 2006 11:04 am Post subject: (No subject) |
|
|
I'd suggst you look into other languages as well. There are other languages that are easier and possibly more fun to experiment with, and Java as a language is pretty mundane.
Oh, and good luck in your academic endeavors. |
|
|
|
|
![](images/spacer.gif) |
|