{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "test.beaker.BeakerTest" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "package test.beaker;\n", "\n", "import java.util.Date;\n", "import java.text.SimpleDateFormat;\n", "\n", "public class BeakerTest {\n", " private Date _date;\n", " private SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy-MM-dd'T'HH:mmZ\");\n", " \n", " public BeakerTest() {\n", " _date = new Date();\n", " }\n", "\n", " public String getDateTxt() {\n", " return \"Today:\" + sdf.format(_date);\n", " }\n", "\n", " public String getDateUpperCaseTxt() {\n", " return getDateTxt().toUpperCase();\n", " }\n", "\n", "}" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Today:2017-12-21T14:47-0500" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "package test.beaker;\n", "\n", "BeakerTest bt = new BeakerTest();\n", "return bt.getDateTxt();" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "794cf94a-c445-41cb-bcc8-17d8a39611a6", "version_major": 2, "version_minor": 0 }, "method": "display_data" }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import java.util.List;\n", "import java.util.ArrayList;\n", "import com.twosigma.beakerx.chart.xychart.Plot;\n", "import com.twosigma.beakerx.chart.xychart.plotitem.*;\n", "import com.twosigma.beakerx.chart.Color;\n", "\n", "Plot p = new Plot();\n", "\n", "p.setTitle(\"this is a Java plot\");\n", "\n", "Bars b = new Bars();\n", "\n", "List yList = new ArrayList();\n", "yList.add(2);\n", "yList.add(5);\n", "yList.add(4);\n", "yList.add(8);\n", "\n", "b.setY(yList);\n", "b.setColor(Color.blue);\n", "b.setWidth(0.5);\n", "\n", "p.add(b);\n", " \n", "return p;" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "test.beaker.DateGetter" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "package test.beaker;\n", "interface DateGetter {\n", " public String getDateTxt();\n", "}" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "test.beaker.DG2" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "package test.beaker;\n", "public class DG2 extends BeakerTest implements DateGetter {\n", "}" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Added jar: [BeakerXClasspathTest.jar]\n" ] } ], "source": [ "%classpath add jar ../../../doc/resources/jar/BeakerXClasspathTest.jar" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The Groovy working folder is :\n", "/Users/spot/src/beakerx/test/notebooks/java\n", "BeakerXClasspathTest.jar exists in this folder\n" ] }, { "data": { "text/plain": [ "null" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "System.out.println(\"The Groovy working folder is :\");\n", "System.out.println(java.nio.file.Paths.get(\".\").toAbsolutePath().normalize().toString());\n", "System.out.println(\"BeakerXClasspathTest.jar exists in this folder\");" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "static_123\n", "object_123\n" ] }, { "data": { "text/plain": [ "null" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import com.beaker.BeakerXClasspathTest;\n", "\n", "BeakerXClasspathTest t = new BeakerXClasspathTest();\n", "System.out.println(com.beaker.BeakerXClasspathTest.staticTest);\n", "System.out.println(t.getObjectTest());" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Java", "language": "java", "name": "java" }, "language_info": { "codemirror_mode": "text/x-java", "file_extension": ".java", "mimetype": "", "name": "Java", "nbconverter_exporter": "", "version": "1.8.0_121" } }, "nbformat": 4, "nbformat_minor": 2 }