Why Code Might Not Run as Expected in Other Places
If you’ve worked through our JavaScript programs you may recognize functions like add()
and setPosition()
along with objects like Rectangle
, Circle
and Randomizer
. These aren't part of the standard JavaScript programming language. We created them specifically for the CodeHS platform.
This means that they won't work in environments outside of CodeHS - unless you download and use the CodeHS library in that environment.
We also use some Java libraries as well.
JavaScript Outside of CodeHS
If you've created a JavaScript program in CodeHS, it won't run correctly without using the JS library which is hosted on our servers. In order to access the CodeHS JS library, you'll need a computer with an internet connection. To use the library with a program, follow these steps:
Create an HTML file with this code:
<html>
<head>
<title>Program Name</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="https://static.codehs.com/gulp/71e31662a311579278c7b569c2b4060584c2b76e/chs-js-lib/chs.js"></script>
<style>
canvas {
border: 1px solid black;
display: inline-block;
vertical-align:
top; }
pre {
border: 1px solid black;
display: inline-block;
width: 400px;
height: 500px;
background-color: #F5F5F5;}
</style>
</head>
<body>
<canvas
width="400"
height="500"
class="codehs-editor-canvas"></canvas>
<pre id="console"></pre>
<script>
window.onload = function() {
// Put your code here! }
</script>
</body>
</html>
2. Paste your JavaScript code in the <script>
tags at the bottom.
3. You can now open your HTML file in your browser and run your program!
Java in Eclipse, BlueJ, and the Terminal
You can view the documentation and download the CodeHS files for the Java Library on GitHub. There is also a short guide for getting started with Eclipse, BlueJ, and the Terminal.
Here are some quick links to download the CodeHS library
Students can also work through a supplemental module on CodeHS with exercises that explore using Java in other environments. View the module here, which is listed under the supplemental sections in the AP Computer Science A course.
Still have questions? Contact our team at hello@codehs.com!