Online compilers that will run code that features TextIO?

  • Thread starter Darkmisc
  • Start date
  • Tags
    Code
In summary, the conversation discusses the use of online compilers for learning coding and the recommendation for using NetBeans or IntelliJ IDEA instead. It also touches on the concept of object-oriented programming and suggests using BlueJ or Processing IDE for beginners before moving on to more advanced IDE tools.
  • #1
198
26
TL;DR Summary
I've been trying to teach myself Java but sometimes can't get the solutions to online problems to compile (both on Eclipse and online compilers).
Hi everyone

I've been trying to teach myself coding using the free materials from https://math.hws.edu/javanotes/index.html

I've been using online compilers because I got a "Error: Could not find or load main class" message immediately upon installing Eclipse.

The online compilers work for some solutions, but won't run others. https://www.programiz.com/java-programming/online-compiler/ is one such compiler. I've tried a few different ones and it seems they all run into problems when I try compile code that uses
- TextIO
- The following code:
Java:
switch (operator) {
              case '+' -> value = firstNum + secondNum;
              case '-' -> value = firstNum - secondNum;
              case '*' -> value = firstNum * secondNum;
              case '/' -> value = firstNum / secondNum;
              default -> {
                 System.out.println("Unknown operator: " + operator);
                 continue;  // Back to start of loop!
              }
          } // end switch
The compilers sometimes work if I use Scanner instead of TextIO or "case x:" instead of "case x ->", but not every compiler will do this and I don't know why.

Can anyone recommend an online compiler that will run with TextIO and "case x ->" notation?

Thanks
 
Last edited by a moderator:
Computer science news on Phys.org
  • #2
Darkmisc said:
I've been using online compilers because I got a "Error: Could not find or load main class" message immediately upon installing Eclipse.
Maybe try NetBeans or IntelliJ IDEA?
Darkmisc said:
- The following code:
switch (operator) {
case '+' -> value = firstNum + secondNum;
case '-' -> value = firstNum - secondNum;
case '*' -> value = firstNum * secondNum;
case '/' -> value = firstNum / secondNum;
default -> {
System.out.println("Unknown operator: " + operator);
continue; // Back to start of loop!
}
} // end switch
Switch expressions were introduced in JDK 12. I bet the online compilers you are using are either supporting Java 8 or JDK 11. TextIO is a 3rd-party library that needs to be added to your project.

If you are a beginner, I strongly suggest you install the latest OpenJDK (JDK 19 being the latest at the time of writing), and also install NetBeans. I used NetBeans instead of Eclipse as a beginner, and it has a fairly flat learning curve. In NetBeans, you can also add external libraries. Those online compilers won't be helpful in the long run.

Later, you can switch to the more advanced IntelliJ IDEA from NetBeans.
 
  • Like
Likes Darkmisc and pbuk
  • #3
Darkmisc said:
I've been trying to teach myself coding using the free materials from https://math.hws.edu/javanotes/index.html
Oh my word, why? And how did you track down such an outdated resource? As you have already discovered Programiz I'd suggest sticking with that - compare and contrast (asserting fair use of copyright material):

JavanotesProgramiz
Object-oriented programming (OOP) represents an attempt to make programs more closely model the way people think about and deal with the world. In the older styles of programming, a programmer who is faced with some problem must identify a computing task that needs to be performed in order to solve the problem. Programming then consists of finding a sequence of instructions that will accomplish that task. But at the heart of object-oriented programming, instead of tasks we find objects—entities that have behaviors, that hold information, and that can interact with one another. Programming consists of designing a set of objects that somehow model the problem at hand. Software objects in the program can represent real or abstract entities in the problem domain. This is supposed to make the design of the program more natural and hence easier to get right and easier to understand.Java is an object-oriented programming language. The core concept of the object-oriented approach is to break complex problems into smaller objects.
To some extent, OOP is just a change in point of view. We can think of an object in standard programming terms as nothing more than a set of variables together with some subroutines for manipulating those variables. In fact, it is possible to use object-oriented techniques in any programming language. However, there is a big difference between a language that makes OOP possible and one that actively supports it. An object-oriented programming language such as Java includes a number of features that make it very different from a standard language. In order to make effective use of those features, you have to "orient" your thinking correctly.
An object is any entity that has a state and behavior. For example, a bicycle is an object. It has
  • States: idle, first gear, etc
  • Behaviors: braking, accelerating, etc.
 
  • Like
Likes Wrichik Basu and Darkmisc
  • #4
Wrichik Basu said:
Maybe try NetBeans or IntelliJ IDEA?
Anything but Eclipse.
 
  • Like
Likes Darkmisc and Wrichik Basu
  • #5
I would look to using BlueJ or Processing IDE to learn about Java programming in a beginner friendly way before venturing into Netbeans, Eclipse or other vendor IDE tools.

BlueJ is specifically designed to be a sandbox for Java. processing uses Java in their sketches which follow the setup() and draw() scheme instead of using a main() function scheme.

https://bluej.org/

https://processing.org/

Processing has a fairly large community and mature set of examples to look at where you can really pickup a lot of Java while writing cool graphics sketches. Processing calls programs sketches.
 
  • Like
Likes Darkmisc
  • #6
jedishrfu said:
I would look to using BlueJ or Processing IDE to learn about Java programming in a beginner friendly way before venturing into Netbeans, Eclipse or other vendor IDE tools.
I haven't used Processing, but the reason why I dislike BlueJ is, they have no quick way of showing the documentation of functions, they don't provide a list of functions when you type something like obj. From my experience, the list of functions, and the ability to view documentation are a huge resource for a beginner who has no idea about all the functions a class has. In addition, good IDEs will give tips like using StringBuilder or StringBuffer instead of String, or using ArrayList instead of arrays if I am creating new arrays every time I need to append or delete something. BlueJ also doesn't have refactoring, so good luck changing the name of a function in a pretty long program. :eek: The last time I emailed them about this issue (5-6 years back), they said that they had no intention of supporting refactoring.

One positive thing about BlueJ is the colouring scheme, which helps newcomers visualize blocks easily. And that's all, probably.
 
  • Like
Likes jedishrfu
  • #7
Yes BlueJ is great for teaching students programming concepts and refactoring doesn’t help with that process as it allows them skip over these suggestions.

Years ago when the personal scientific calculator overtook the sliderule in college, I witnessed the after-effects. Some students doing an electrical experiment concluded that the circuit with the 12v battery was actually generating 12000v.

When asked how they got that answer, they said that’s what the calculator computed and we knew they missed a few decimal points somewhere that would not have happened had they used a sliderule and thought about it more.

One thing in BlueJ’s favor is the class diagrams it makes that visualizes your program.

Processing doesn’t support the dot expansion either unless you use a variant of the IDE that is based on Eclipse. I’m not sure if that still exists with the latest Processing 4 IDE.

EDIT: There is an extension tool for Processing 3 not yet 4 that provides a Java api reference and another that works with Processing 4 that does (if, for, while) … expansion when ctrl-space is pressed after typing the word (if, for, while).
 
Last edited:
  • Like
Likes Darkmisc and Wrichik Basu

1. How do online compilers with TextIO work?

Online compilers with TextIO work by taking user-written code and running it through a virtual machine that executes the code and displays the output. The TextIO feature allows the user to input and output text within the code, making it more interactive and user-friendly.

2. What languages are supported by online compilers with TextIO?

The languages supported by online compilers with TextIO vary depending on the specific website or platform. However, some commonly supported languages include Java, C++, Python, and JavaScript.

3. Are online compilers with TextIO secure?

This depends on the specific website or platform. It is important to research and choose a reputable and secure online compiler with TextIO. Additionally, it is always recommended to avoid inputting sensitive information into any online platform.

4. Can I save and share my code using online compilers with TextIO?

Again, this depends on the specific website or platform. Some online compilers with TextIO allow users to save and share their code, while others may not have this feature. It is important to read the website's instructions or terms of use to determine this.

5. Are there any limitations to using online compilers with TextIO?

Yes, there may be limitations to using online compilers with TextIO depending on the website or platform. Some common limitations include a maximum number of lines of code, limited storage space, and restricted access to certain libraries or features. It is important to read the website's instructions or terms of use to determine any limitations.

Suggested for: Online compilers that will run code that features TextIO?

Back
Top