Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Nisha Gor   on Dec 26 In Java Category.

  
Question Answered By: Randall Franklin   on Dec 26

I recommend putting *all* your java  source files  in one single tree.
Then only compile  the main java file. Sometimes you need to compile
more java files.

src (dir, c:\programming\src for instance)
+- com (dir)
...+- yourcompanyname (dir)
......+- app (dir)
........+- test (dir)
...........+- SomeTest.java (file)
......+- util (dir)
........+- Util.java (file)

SomeTest.java file:

package com.yourcompanyname.app.test;

import java.io.*;
import com.yourcompanyname.util.Util;

public class  SomeTest
{
public static void main(String[] args)
{
Util util = new Util();
InputStream is = new FileInputStream(".");
}
}

Compile with:
javac -sourcepath pathtosrc com/yourcompanyname/app/test/SomeTest.java

run:
java com.yourcompanyname.app.test.SomeTest

And to former C and C++'ers, do not write Makefile's with .java to
.class translation rules. A java file translates to one *OR MORE*
class files. In Java you don't have a build process figure out how to
generate a class file, but you simple throw all your source to the
compiler all at once.

If you ever get fed up with the compilation speed of javac, try IBM's
jikes. It's a replacement command line java compiler that's
rediculously fast. You can write java source files till the cows come
home, but they will always compile in a couple of seconds.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on problem with class import Or get search suggestion and latest updates.


Tagged: