New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Operating System General OS operation information and support

quick help with terminal command


Post Reply New Thread Subscribe

 
Thread Tools
MKoop

 
Member Since: Sep 12, 2009
Posts: 31
MKoop is on a distinguished road

MKoop is offline
Could anyone tell me the command for compile in terminal? Trying to compile some java documents to run.
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 18,050
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
If it's Java, try the following:
Code:
javac <name of file>
Replace <name of file> with the .java file. That will create the required class files. Then, simply execute the following to run it:
Code:
java <name of class file>
One thing to note here that is important - do not include the .class extension when executing java in that last command. For example, you would execute:
Code:
java MyClassFile
instead of:
Code:
java MyClassFile.class

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
MKoop

 
Member Since: Sep 12, 2009
Posts: 31
MKoop is on a distinguished road

MKoop is offline
Thanks, I knew how it all works just on DOS just didn't know what to replace the dos "compile" and "run" commands with for terminal. Having a few speed bumps in the transition but hoping its worth it in the long run.

+rep for quick and accurate reply

Thanks again.
QUOTE Thanks
MKoop

 
Member Since: Sep 12, 2009
Posts: 31
MKoop is on a distinguished road

MKoop is offline
Having another issue now, maybe I am pointing to the file incorrectly? Hiccups learning terminal, forgive me. This is my error:

my terminal command:
matthew-lastname-MacBook-Pro-2:~ Matt$ javac Documents/Professional/2011_Seg_C/java/Countertest.java



result:

Matt$ Documents/Professional/2011_Seg_C/java/ \\The previous is abbreviated in the following:

java/CounterTest.java
java/CounterTest.java: line 2: /Applications: is a directory
java/CounterTest.java: line 3: 2010_BikeMapForWeb.pdf: command not found
java/CounterTest.java: line 4: 2010_BikeMapForWeb.pdf: command not found
java/CounterTest.java: line 5: 2010_BikeMapForWeb.pdf: command not found
java/CounterTest.java: line 6: Desktop/: is a directory
java/CounterTest.java: line 7: public: command not found
java/CounterTest.java: line 8: /Applications: is a directory
java/CounterTest.java: line 9: 2010_BikeMapForWeb.pdf: command not found
java/CounterTest.java: line 10: 2010_BikeMapForWeb.pdf: command not found
java/CounterTest.java: line 11: 2010_BikeMapForWeb.pdf: command not found
java/CounterTest.java: line 12: Desktop/: is a directory
java/CounterTest.java: line 13: syntax error near unexpected token `('
java/CounterTest.java: line 13: ` public static void main(String[] args) {'


I saw this and am bewildered and not even sure what to think as I have only coded a very basic counter. Why is this targeting my city bike path route pdf and such? This makes absolutely no sense to me. I have included my code below:


/**
* Description of the Class
*
* @author XXXX
*/
public class Countertest {
/**
* This is the main method for this class
*
* @param args
*/
public static void main(String[] args) {
int counter;
counter = 0;
while (counter <= 10) {
counter++;
System.out.println("counter" + counter) ("counter" + counter*counter);
}

}
}


Maybe I should move this question to a different section of the forums?
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 18,050
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
Yes, programming questions should be in the development forum.

In the meantime, I tried to compile the code and got 3 errors all to do with the println line. It makes sense - why do you have the ("counter" + counter*counter) after the println statement?

Another thing to note - the name of your file and the name of the class have to be exactly the same. While you have the same word, the case has to be the same as well. So, either name the file Countertest.java or rename the class CounterTest.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
MKoop

 
Member Since: Sep 12, 2009
Posts: 31
MKoop is on a distinguished road

MKoop is offline
The class designations was actually an error on my part because when I copy and pasted the code I didn't think the file name was capitalized. (but it is in reality).

I'm no expert and am still learning java. The ("counter" + counter*counter) after the println statement is in response to the following requirement:

"In the while loop, output the counter variable. Then output counter squared on the same line with a space in between the two values."

I tried to run even some very basic code:

/**
* This is the main method for this class
*
*
* @author XXXXXX
* @param args
*/

public class testcheck {
public static void main(String[] args) {
int one;
String name;
one = 25;
name = "Fred";
System.out.println("The integer is: " + one + "\n"
+ "The name is: " + name);
}
}

with the following:

Matthew-lastname-MacBook-Pro-2:~ Matt$ javac Documents/Professional/java/testcheck.java


Documents/Professional/java/testcheck.java:20: illegal character: \0

^
Documents/Professional/java/testcheck.java:20: illegal character: \0

^
Documents/Professional/java/testcheck.java:20: illegal character: \0

(This error repeats 100x)

--This compiled and ran with no errors in DOS

I know java is integrated, but is there anything at all I need to download that could be causing this? An update or package or anything?
QUOTE Thanks

Post Reply New Thread Subscribe


« What's safe to move | Stumped on Connecting from XP to Mac Shared Folder »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Command ln -s does not work (no feedback at all in terminal) dysprosium OS X - Operating System 0 01-27-2010 05:28 AM
find command in terminal -- listing files twice Straitsfan OS X - Apps and Games 3 01-10-2010 09:46 PM
Backtracking on a terminal command Sedlex OS X - Operating System 2 08-27-2009 09:57 AM
Terminal problems please help CliveO OS X - Operating System 6 03-20-2007 10:04 AM
The mysterious Terminal Kokopelli OS X - Operating System 2 03-05-2006 08:23 AM

All times are GMT -4. The time now is 09:31 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?