3

I am doing JAVA project based on the SSJ (Stochastic Simulation in Java) libraries. In my project I have followed the required steps to import the SSJ library files and also the source files.

When looking at the SSJ library files in the project's Libraries branch, only class files appear shown, but when I open them I can view the source code (which I couldn't before, as I hadn't imported the sources) so I assume everything was imported correctly.

When I run the examples provided with the library everything runs fine and as expected. But if I try to change the source code for the libraries for instance, changing the text on an output, the changes I make to the source files aren't reflected in the output from the java programs.

Any hint on what I might be doing wrong?

I understand this might be hard to understand or test as I can't quite create and SSCCE for this matter. The library files are hosted here (http://www.iro.umontreal.ca/~simardr/ssj/ssj-20120216.zip) and the source code here (http://www.iro.umontreal.ca/~simardr/ssj/ssj-source.html).

Thanks in advance for all your help!

  • 2
    When you add source for a library it's for debugging purposes, it does not mean that Netbeans will detect changes and recompile. Either you have to add the source to your project and remove the jar references or you need to create a project for the library itself and add that project as reference. – madth3 Jul 03 '12 at 15:23
  • @madth3 Your comment looks like a complete and correct answer to me, it would be better to post it as such. – fvu Jul 03 '12 at 15:29
  • @fvu Thanks for the encouragement. – madth3 Jul 03 '12 at 15:41

2 Answers2

3

Adding source to libraries it's for debugging and documentation purposes. It does not mean that Netbeans will detect changes and recompile classes automatically.

You should create a project for the library itself to recreate it from source. Changes are that if you have the source there will be a build.xmlor a pom.xml that contains the steps to compile the library and will allow to create a Java Free Form Project or a Project with existing POM.

You'd then remove the reference to library itself and add a dependency to the project.

Other option would be to add the library source to the same project you are using (and, again, removing reference to the library) but I would not recommend this unless it's a very small simple library.

EDIT. Particular ssj information.

ssj is a library where the original source code is in .tex files and it requires several programs available to generate .java files and then compile them. All this information can be found in the COMPILE.txt original file.

Since the source distribution includes .java files it is possible to generate a .jar just using Netbeans but it requires to modify the build.xml to just compile Java source files. Also when creating the Java Free Form Project is necessary to select lib as the target to Build Project.

Here it's a minimal build xml for Netbeans 7.1 to compile from Java sources.

madth3
  • 7,275
  • 12
  • 50
  • 74
  • I tried to add the library source to the same project, but since it isn't a small library it wouldn't be feasible! The source is available and has indeed a build.xml file! I did however try to create a Java Free Form Project from the existing library but failed to succeed as I couldn't compile the project (not sure if I am supposed to anyway). This meaning, I couldn add a project to the Libraries from the previous project where I had imported the library jar files. I understand what you meant, but can't seem to get it across! – Luis Afonso Teixeira Jul 03 '12 at 15:59
  • 1
    You can add the library project itself as a dependency to your project and forget about the Libraries list. – madth3 Jul 03 '12 at 16:01
  • By creating a Java Free Form Project and then add it as a dependency to my project right? As i've said, I tried, but couldn't add it! – Luis Afonso Teixeira Jul 03 '12 at 17:09
  • There are some warnings on the files and when I try to compile this is what I get outputed: D:\WORK\ISEP\MESTRADO\TESE\JAVA\Libraries\SSJ\ssj-2.5-source\ssj-2.5\build.xml:30: taskdef class umontreal.iro.lecuyer.tcode.Texjava cannot be found using the classloader AntClassLoader[] – Luis Afonso Teixeira Jul 03 '12 at 17:32
  • Well, reading the `COMPILE.txt` it seems that unfortunately `ssj` is not a regular Java library. Did you try calling just the `lib` task in the `build.xml` instead of the default? – madth3 Jul 03 '12 at 18:16
  • I'm sorry but I don't understand what you mean with calling just the lib task? COuld you please explain? Btw, thanks for taking your time to download and go throught the files, much appreciated! – Luis Afonso Teixeira Jul 03 '12 at 18:39
  • I've added some extra info and a streamlined `build.xml` that works with NB 7.1. – madth3 Jul 03 '12 at 19:36
  • I really, really appreciate your time and effort on helping me solve this issue! I downloaded your file, and pointed it as the xml file to build the project (instead of the original build.xml)! That was what I was supposed to do right? But NetBeans states the file is not a valid Ant script. – Luis Afonso Teixeira Jul 03 '12 at 20:29
  • I think there was a wrong extra blank line at the top of the file. Try removing that. – madth3 Jul 03 '12 at 23:10
  • I made it! It was the blank line indeed, I managed to do as you instructed me and I can now edit the source class/java files! Thank you very much! One thing I noticed, now when I change my java files and compile them, NetBeans compiles more files than the ones I edited and also takes a bit more time to run than previously! Is that supposed to happen? – Luis Afonso Teixeira Jul 04 '12 at 00:06
  • The original file compiles things by module and it might be recompiling more than it should. I really don't know why it would be slower but is clear to me that the `build.xml` is missing something from the original compilation process. – madth3 Jul 04 '12 at 00:26
0

In order to create the new *.java file from the *.tex file, you need the tcode.jar which is available in the distribution. Have you added tcode.jar as an external jar to your project?

umontreal.iro.lecuyer.tcode.Texjava is in tcode.jar