Home arrow static arrow Java Programming [Archive] - getting java code to compile on unix/linux
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - getting java code to compile on unix/linux
This topic has 5 replies on 1 page.

Posts:48
Registered: 10/3/03
getting java code to compile on unix/linux  
Jul 26, 2004 1:45 PM



 
I have been using borland JBuilder to run and compile my java code. Recently i tried moving the code to a linux machine in which i have downloaded the JDK to. My classes only use standard java classes with the exception of a jbcl.jar file which has a class that one of my classes relies on. It turns out when i try to run my class i get error messages because it cant find the jar file. Where should I put this jar file? by the way in my class i use the statement: where jbcl.layout is the class i need.
import jbcl.layout.*;
 

Posts:21,719
Registered: 98-02-20
Re: getting java code to compile on unix/linux  
Jul 26, 2004 1:58 PM (reply 1 of 5)



 
It's the same answer regardless of platform:

You should put the JAR file anywhere you wish, preferrably close to the rest of your .class files, and add it to the CLASSPATH using the -classpath option on javac.exe for compiling and java.exe for running.

%
 

Posts:1,657
Registered: 1/8/98
Re: getting java code to compile on unix/linux  
Jul 26, 2004 9:13 PM (reply 2 of 5)



 
Psst - duffy! Besides the fact that I seem to be following you around this evening (my time), "javac.exe" and "java.exe" won't work on Linux/Unix. Other than that, you were spot on.
 

Posts:48
Registered: 10/3/03
Re: getting java code to compile on unix/linux  
Jul 27, 2004 9:11 AM (reply 3 of 5)



 
another question. In my class I use the statement
import jbcl.layout.*;

so all i need to do is add the jbcl.jar to my class path? is my import statement correct
 

Posts:37,103
Registered: 3/30/99
Re: getting java code to compile on unix/linux  
Jul 27, 2004 9:15 AM (reply 4 of 5)



 
another question. In my class I use the statement
import jbcl.layout.*;

so all i need to do is add the jbcl.jar to my class
path? is my import statement correct

If it compiles in your IDE, then it's correct. You shouldn't have to change anything at all in your source code to use a different compiler or to compile on a different platform. You just have set up the proper environment and parameters--tell it which .java files to compile, which jars or directories to search for classes in (classpath), etc. For IDEs you do that with the Preferences or Options menu item. For command line compilation you do this with command line arguments, config files (a la build.xml for ant), or environment variables (although relying on the CLASSPATH env var is generally a bad idea).
 

Posts:18,384
Registered: 21.03.00
Re: getting java code to compile on unix/linux  
Jul 27, 2004 10:34 AM (reply 5 of 5)



 
another question. In my class I use the statement
import jbcl.layout.*;

so all i need to do is add the jbcl.jar to my class
path? is my import statement correct

Yes that is correct.
Have you considered to include the required classes within your jar?

/Kaj
 
This topic has 5 replies on 1 page.