NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Easy Java Simulations (2001- ) => Questions related to EJS => Topic started by: lookang on January 07, 2009, 04:52:57 pm



Title: How to add Java Source: Calc3.java into EJS ?
Post by: lookang on January 07, 2009, 04:52:57 pm
How to add Java Source: Calc3.java into EJS ?


reference: http://www.mste.uiuc.edu/users/exner/java.f/calc/
Arbitrary Precision Calculator

      Please click on the Calculator button to turn on the calculator.

      Error: Your browser is not java enabled.

Java Source: Calc3.java

1. Is there a import button?

2. Or is it a copy and paste into custom function ?

Thanks!


Title: Re: How to add Java Source: Calc3.java into EJS ?
Post by: Fu-Kwun Hwang on January 07, 2009, 11:14:28 pm
You can add java functions into custom functions.

Actually, you can also add java class files or jar file.
You will find "additional libraries" button (to import jar or class) at custom page.

For example: EJS use many libraries from opensourcephysics project and other open source code.


Title: Re: How to add Java Source: Calc3.java into EJS ?
Post by: lookang on January 08, 2009, 07:47:58 am
You can add java functions into custom functions.
Actually, you can also add java class files or jar file.
You will find "additional libraries" button (to import jar or class) at custom page.


1.  start a new file
2. navigate to custom page
3. right click for more options to import file.java that is saved in the workspace (http://www.phy.ntnu.edu.tw/ntnujava/index.php?action=dlattach;topic=857.0;attach=558;image)
4. though it say error in import
5. the is a button called set external java file so i select the file.java again(http://www.phy.ntnu.edu.tw/ntnujava/index.php?action=dlattach;topic=857.0;attach=561;image)
6. this time the code is imported
7. click RUN a red screen appear(http://www.phy.ntnu.edu.tw/ntnujava/index.php?action=dlattach;topic=857.0;attach=563;image)
8. what must be done to proceed to be able to build the interface or is it automatically since the external file.java seems to have draw syntax i think?

thanks

I attached the source.xml for easy reference :)










Title: Re: How to add Java Source: Calc3.java into EJS ?
Post by: Fu-Kwun Hwang on January 08, 2009, 09:05:31 pm
The import button is for generated java .class  or .jar file (so called java byte code.),
It is not for java source code.

You have found a way to import java source.
But I thinj your example would not work. Because what you have imported is an applet. I do not know there is a way to add another applet inside another applet. (You can add drawingPanel inside another draeingPanel).
The java code you tried to import is a complete java applet. You can not put that inside an ejs applet.
You need to remove some of the code to make it work.

I was not able to try out your xml because you did not attach Calc3.java


Title: Re: How to add Java Source: Calc3.java into EJS ?
Post by: lookang on January 08, 2009, 09:53:44 pm
thanks for giving your time to explain this ;D