Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
I had found a better way to plot in Java. int n = Integer.parseInt(args[0]); // the function y = sin(4x) + sin(20x), sampled at n+1 points // between x = 0 and x = pi ...
#6: Post edited
- I had found a better way to plot in Java.
- ```java
- int n = Integer.parseInt(args[0]);
- // the function y = sin(4x) + sin(20x), sampled at n+1 points
- // between x = 0 and x = pi
- double[] x = new double[n+1];
- double[] y = new double[n+1];
- for (int i = 0; i <= n; i++) {
- x[i] = Math.PI * i / n;
- y[i] = Math.sin(4*x[i]) + Math.sin(20*x[i]);
- }
- // rescale the coordinate system
- StdDraw.setXscale(0, Math.PI);
- StdDraw.setYscale(-2.1, +2.1);
- // plot the approximation to the function
- for (int i = 0; i < n; i++) {
- StdDraw.line(x[i], y[i], x[i+1], y[i+1]);
- }
- ```
- I don't have the StdDraw class. I was searching in internet what should I do to import the class. I had seen that they said to use
- ```java
- import StdDraw;
- //or
- import stddraw.StdDraw;
- //or
- import StdDraw.*;
- ```
- None of them are helpful cause I don't have the StdDraw package. I had found [it](https://introcs.cs.princeton.edu/java/stdlib/) then. I can see StdDraw there. But I don't have any idea how can I convert that .java.html to .jar. I had found [it](https://stackoverflow.com/a/32853178) to import the package. But the problem is I can't download the package at first.
- ![No Project Structure](https://imgur.com/dSj7GGr.png)
- What!! I can't see any project structure option in netbeans. Ohh They had wrote the answer for IntelliJ. But I am using Netbeans. Even I don't have any file called `/lib`. I know that I have to put a line in gradle.build
- ```gradle
- implementation 'file_name'
- ```
- But I don't have any idea where I should put that jar file. I have created a folder called libs and pasted that jar file there. Then added the line to gradle.build
- ```gradle
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- ```
- I have re-sync my project. Although I can't find that StdDraw class. I have tried to import that class manually..
- ```java
- import stdlib.StdDraw;
- ```
But `stdlib` doesn't exist. That's what I am getting as error.
- I had found a better way to plot in Java.
- ```java
- int n = Integer.parseInt(args[0]);
- // the function y = sin(4x) + sin(20x), sampled at n+1 points
- // between x = 0 and x = pi
- double[] x = new double[n+1];
- double[] y = new double[n+1];
- for (int i = 0; i <= n; i++) {
- x[i] = Math.PI * i / n;
- y[i] = Math.sin(4*x[i]) + Math.sin(20*x[i]);
- }
- // rescale the coordinate system
- StdDraw.setXscale(0, Math.PI);
- StdDraw.setYscale(-2.1, +2.1);
- // plot the approximation to the function
- for (int i = 0; i < n; i++) {
- StdDraw.line(x[i], y[i], x[i+1], y[i+1]);
- }
- ```
- I don't have the StdDraw class. I was searching in internet what should I do to import the class. I had seen that they said to use
- ```java
- import StdDraw;
- //or
- import stddraw.StdDraw;
- //or
- import StdDraw.*;
- ```
- None of them are helpful cause I don't have the StdDraw package. I had found [it](https://introcs.cs.princeton.edu/java/stdlib/) then. I can see StdDraw there. But I don't have any idea how can I convert that .java.html to .jar. I had found [it](https://stackoverflow.com/a/32853178) to import the package. But the problem is I can't download the package at first.
- ![No Project Structure](https://imgur.com/dSj7GGr.png)
- What!! I can't see any project structure option in netbeans. Ohh They had wrote the answer for IntelliJ. But I am using Netbeans. Even I don't have any file called `/lib`. I know that I have to put a line in gradle.build
- ```gradle
- implementation 'file_name'
- ```
- But I don't have any idea where I should put that jar file. I have created a folder called libs and pasted that jar file there. Then added the line to gradle.build
- ```gradle
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- ```
- I have re-sync my project. Although I can't find that StdDraw class. I have tried to import that class manually..
- ```java
- import stdlib.StdDraw;
- ```
- But `stdlib` doesn't exist. That's what I am getting as error. ~ I was following [the answer](https://stackoverflow.com/a/48930705/16897106)
#5: Post edited
How to install a package in Netbeans?
- Why I am unable to find a class after implementing library also?
- I had found a better way to plot in Java.
- ```java
- int n = Integer.parseInt(args[0]);
- // the function y = sin(4x) + sin(20x), sampled at n+1 points
- // between x = 0 and x = pi
- double[] x = new double[n+1];
- double[] y = new double[n+1];
- for (int i = 0; i <= n; i++) {
- x[i] = Math.PI * i / n;
- y[i] = Math.sin(4*x[i]) + Math.sin(20*x[i]);
- }
- // rescale the coordinate system
- StdDraw.setXscale(0, Math.PI);
- StdDraw.setYscale(-2.1, +2.1);
- // plot the approximation to the function
- for (int i = 0; i < n; i++) {
- StdDraw.line(x[i], y[i], x[i+1], y[i+1]);
- }
- ```
- I don't have the StdDraw class. I was searching in internet what should I do to import the class. I had seen that they said to use
- ```java
- import StdDraw;
- //or
- import stddraw.StdDraw;
- //or
- import StdDraw.*;
- ```
- None of them are helpful cause I don't have the StdDraw package. I had found [it](https://introcs.cs.princeton.edu/java/stdlib/) then. I can see StdDraw there. But I don't have any idea how can I convert that .java.html to .jar. I had found [it](https://stackoverflow.com/a/32853178) to import the package. But the problem is I can't download the package at first.
- ![No Project Structure](https://imgur.com/dSj7GGr.png)
- What!! I can't see any project structure option in netbeans. Ohh They had wrote the answer for IntelliJ. But I am using Netbeans. Even I don't have any file called `/lib`. I know that I have to put a line in gradle.build
- ```gradle
- implementation 'file_name'
- ```
But I don't have any idea where I should put that jar file.
- I had found a better way to plot in Java.
- ```java
- int n = Integer.parseInt(args[0]);
- // the function y = sin(4x) + sin(20x), sampled at n+1 points
- // between x = 0 and x = pi
- double[] x = new double[n+1];
- double[] y = new double[n+1];
- for (int i = 0; i <= n; i++) {
- x[i] = Math.PI * i / n;
- y[i] = Math.sin(4*x[i]) + Math.sin(20*x[i]);
- }
- // rescale the coordinate system
- StdDraw.setXscale(0, Math.PI);
- StdDraw.setYscale(-2.1, +2.1);
- // plot the approximation to the function
- for (int i = 0; i < n; i++) {
- StdDraw.line(x[i], y[i], x[i+1], y[i+1]);
- }
- ```
- I don't have the StdDraw class. I was searching in internet what should I do to import the class. I had seen that they said to use
- ```java
- import StdDraw;
- //or
- import stddraw.StdDraw;
- //or
- import StdDraw.*;
- ```
- None of them are helpful cause I don't have the StdDraw package. I had found [it](https://introcs.cs.princeton.edu/java/stdlib/) then. I can see StdDraw there. But I don't have any idea how can I convert that .java.html to .jar. I had found [it](https://stackoverflow.com/a/32853178) to import the package. But the problem is I can't download the package at first.
- ![No Project Structure](https://imgur.com/dSj7GGr.png)
- What!! I can't see any project structure option in netbeans. Ohh They had wrote the answer for IntelliJ. But I am using Netbeans. Even I don't have any file called `/lib`. I know that I have to put a line in gradle.build
- ```gradle
- implementation 'file_name'
- ```
- But I don't have any idea where I should put that jar file. I have created a folder called libs and pasted that jar file there. Then added the line to gradle.build
- ```gradle
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- ```
- I have re-sync my project. Although I can't find that StdDraw class. I have tried to import that class manually..
- ```java
- import stdlib.StdDraw;
- ```
- But `stdlib` doesn't exist. That's what I am getting as error.
#4: Post edited
- I had found a better way to plot in Java.
- ```java
- int n = Integer.parseInt(args[0]);
- // the function y = sin(4x) + sin(20x), sampled at n+1 points
- // between x = 0 and x = pi
- double[] x = new double[n+1];
- double[] y = new double[n+1];
- for (int i = 0; i <= n; i++) {
- x[i] = Math.PI * i / n;
- y[i] = Math.sin(4*x[i]) + Math.sin(20*x[i]);
- }
- // rescale the coordinate system
- StdDraw.setXscale(0, Math.PI);
- StdDraw.setYscale(-2.1, +2.1);
- // plot the approximation to the function
- for (int i = 0; i < n; i++) {
- StdDraw.line(x[i], y[i], x[i+1], y[i+1]);
- }
- ```
- I don't have the StdDraw class. I was searching in internet what should I do to import the class. I had seen that they said to use
- ```java
- import StdDraw;
- //or
- import stddraw.StdDraw;
- //or
- import StdDraw.*;
- ```
- None of them are helpful cause I don't have the StdDraw package. I had found [it](https://introcs.cs.princeton.edu/java/stdlib/) then. I can see StdDraw there. But I don't have any idea how can I convert that .java.html to .jar. I had found [it](https://stackoverflow.com/a/32853178) to import the package. But the problem is I can't download the package at first.
- ![No Project Structure](https://imgur.com/dSj7GGr.png)
What!! I can't see any project structure option in netbeans. Ohh They had wrote the answer for IntelliJ. But I am using Netbeans. Even I don't have any file called `/lib`.
- I had found a better way to plot in Java.
- ```java
- int n = Integer.parseInt(args[0]);
- // the function y = sin(4x) + sin(20x), sampled at n+1 points
- // between x = 0 and x = pi
- double[] x = new double[n+1];
- double[] y = new double[n+1];
- for (int i = 0; i <= n; i++) {
- x[i] = Math.PI * i / n;
- y[i] = Math.sin(4*x[i]) + Math.sin(20*x[i]);
- }
- // rescale the coordinate system
- StdDraw.setXscale(0, Math.PI);
- StdDraw.setYscale(-2.1, +2.1);
- // plot the approximation to the function
- for (int i = 0; i < n; i++) {
- StdDraw.line(x[i], y[i], x[i+1], y[i+1]);
- }
- ```
- I don't have the StdDraw class. I was searching in internet what should I do to import the class. I had seen that they said to use
- ```java
- import StdDraw;
- //or
- import stddraw.StdDraw;
- //or
- import StdDraw.*;
- ```
- None of them are helpful cause I don't have the StdDraw package. I had found [it](https://introcs.cs.princeton.edu/java/stdlib/) then. I can see StdDraw there. But I don't have any idea how can I convert that .java.html to .jar. I had found [it](https://stackoverflow.com/a/32853178) to import the package. But the problem is I can't download the package at first.
- ![No Project Structure](https://imgur.com/dSj7GGr.png)
- What!! I can't see any project structure option in netbeans. Ohh They had wrote the answer for IntelliJ. But I am using Netbeans. Even I don't have any file called `/lib`. I know that I have to put a line in gradle.build
- ```gradle
- implementation 'file_name'
- ```
- But I don't have any idea where I should put that jar file.
#3: Post edited
How to install a package?
- How to install a package in Netbeans?
- I had found a better way to plot in Java.
- ```java
- int n = Integer.parseInt(args[0]);
- // the function y = sin(4x) + sin(20x), sampled at n+1 points
- // between x = 0 and x = pi
- double[] x = new double[n+1];
- double[] y = new double[n+1];
- for (int i = 0; i <= n; i++) {
- x[i] = Math.PI * i / n;
- y[i] = Math.sin(4*x[i]) + Math.sin(20*x[i]);
- }
- // rescale the coordinate system
- StdDraw.setXscale(0, Math.PI);
- StdDraw.setYscale(-2.1, +2.1);
- // plot the approximation to the function
- for (int i = 0; i < n; i++) {
- StdDraw.line(x[i], y[i], x[i+1], y[i+1]);
- }
- ```
- I don't have the StdDraw class. I was searching in internet what should I do to import the class. I had seen that they said to use
- ```java
- import StdDraw;
- //or
- import stddraw.StdDraw;
- //or
- import StdDraw.*;
- ```
- None of them are helpful cause I don't have the StdDraw package. I had found [it](https://introcs.cs.princeton.edu/java/stdlib/) then. I can see StdDraw there. But I don't have any idea how can I convert that .java.html to .jar. I had found [it](https://stackoverflow.com/a/32853178) to import the package. But the problem is I can't download the package at first.
- ![No Project Structure](https://imgur.com/dSj7GGr.png)
What!! I can't see any project structure option in netbeans. I am running Gradle Project. I am more familiar with Gradle rather than Maven.
- I had found a better way to plot in Java.
- ```java
- int n = Integer.parseInt(args[0]);
- // the function y = sin(4x) + sin(20x), sampled at n+1 points
- // between x = 0 and x = pi
- double[] x = new double[n+1];
- double[] y = new double[n+1];
- for (int i = 0; i <= n; i++) {
- x[i] = Math.PI * i / n;
- y[i] = Math.sin(4*x[i]) + Math.sin(20*x[i]);
- }
- // rescale the coordinate system
- StdDraw.setXscale(0, Math.PI);
- StdDraw.setYscale(-2.1, +2.1);
- // plot the approximation to the function
- for (int i = 0; i < n; i++) {
- StdDraw.line(x[i], y[i], x[i+1], y[i+1]);
- }
- ```
- I don't have the StdDraw class. I was searching in internet what should I do to import the class. I had seen that they said to use
- ```java
- import StdDraw;
- //or
- import stddraw.StdDraw;
- //or
- import StdDraw.*;
- ```
- None of them are helpful cause I don't have the StdDraw package. I had found [it](https://introcs.cs.princeton.edu/java/stdlib/) then. I can see StdDraw there. But I don't have any idea how can I convert that .java.html to .jar. I had found [it](https://stackoverflow.com/a/32853178) to import the package. But the problem is I can't download the package at first.
- ![No Project Structure](https://imgur.com/dSj7GGr.png)
- What!! I can't see any project structure option in netbeans. Ohh They had wrote the answer for IntelliJ. But I am using Netbeans. Even I don't have any file called `/lib`.
#2: Post edited
- I had found a better way to plot in Java.
- ```java
- int n = Integer.parseInt(args[0]);
- // the function y = sin(4x) + sin(20x), sampled at n+1 points
- // between x = 0 and x = pi
- double[] x = new double[n+1];
- double[] y = new double[n+1];
- for (int i = 0; i <= n; i++) {
- x[i] = Math.PI * i / n;
- y[i] = Math.sin(4*x[i]) + Math.sin(20*x[i]);
- }
- // rescale the coordinate system
- StdDraw.setXscale(0, Math.PI);
- StdDraw.setYscale(-2.1, +2.1);
- // plot the approximation to the function
- for (int i = 0; i < n; i++) {
- StdDraw.line(x[i], y[i], x[i+1], y[i+1]);
- }
- ```
- I don't have the StdDraw class. I was searching in internet what should I do to import the class. I had seen that they said to use
- ```java
- import StdDraw;
- //or
- import stddraw.StdDraw;
- //or
- import StdDraw.*;
- ```
None of them are helpful cause I don't have the StdDraw package. I had found [it](https://introcs.cs.princeton.edu/java/stdlib/) then. I can see StdDraw there. But I don't have any idea how can I convert that .java.html to .jar. I had found [it](https://stackoverflow.com/a/32853178) to import the package. But the problem is I can't download the package at first.
- I had found a better way to plot in Java.
- ```java
- int n = Integer.parseInt(args[0]);
- // the function y = sin(4x) + sin(20x), sampled at n+1 points
- // between x = 0 and x = pi
- double[] x = new double[n+1];
- double[] y = new double[n+1];
- for (int i = 0; i <= n; i++) {
- x[i] = Math.PI * i / n;
- y[i] = Math.sin(4*x[i]) + Math.sin(20*x[i]);
- }
- // rescale the coordinate system
- StdDraw.setXscale(0, Math.PI);
- StdDraw.setYscale(-2.1, +2.1);
- // plot the approximation to the function
- for (int i = 0; i < n; i++) {
- StdDraw.line(x[i], y[i], x[i+1], y[i+1]);
- }
- ```
- I don't have the StdDraw class. I was searching in internet what should I do to import the class. I had seen that they said to use
- ```java
- import StdDraw;
- //or
- import stddraw.StdDraw;
- //or
- import StdDraw.*;
- ```
- None of them are helpful cause I don't have the StdDraw package. I had found [it](https://introcs.cs.princeton.edu/java/stdlib/) then. I can see StdDraw there. But I don't have any idea how can I convert that .java.html to .jar. I had found [it](https://stackoverflow.com/a/32853178) to import the package. But the problem is I can't download the package at first.
- ![No Project Structure](https://imgur.com/dSj7GGr.png)
- What!! I can't see any project structure option in netbeans. I am running Gradle Project. I am more familiar with Gradle rather than Maven.
#1: Initial revision
How to install a package?
I had found a better way to plot in Java. ```java int n = Integer.parseInt(args[0]); // the function y = sin(4x) + sin(20x), sampled at n+1 points // between x = 0 and x = pi double[] x = new double[n+1]; double[] y = new double[n+1]; for (int i = 0; i <= n; i++) { x[i] = Math.PI * i / n; y[i] = Math.sin(4*x[i]) + Math.sin(20*x[i]); } // rescale the coordinate system StdDraw.setXscale(0, Math.PI); StdDraw.setYscale(-2.1, +2.1); // plot the approximation to the function for (int i = 0; i < n; i++) { StdDraw.line(x[i], y[i], x[i+1], y[i+1]); } ``` I don't have the StdDraw class. I was searching in internet what should I do to import the class. I had seen that they said to use ```java import StdDraw; //or import stddraw.StdDraw; //or import StdDraw.*; ``` None of them are helpful cause I don't have the StdDraw package. I had found [it](https://introcs.cs.princeton.edu/java/stdlib/) then. I can see StdDraw there. But I don't have any idea how can I convert that .java.html to .jar. I had found [it](https://stackoverflow.com/a/32853178) to import the package. But the problem is I can't download the package at first.