Skip to content

Latest commit

 

History

History
62 lines (40 loc) · 2.46 KB

File metadata and controls

62 lines (40 loc) · 2.46 KB

psjava

npm CI license

Run .psjava files as scripts — plain Java on top of JShell, with zero ceremony.

There's no custom syntax and no transpilation: whatever is in the file is exactly what jshell runs. psjava only adds a small print helper to the session and strips the Windows BOM — nothing else touches your code.

Install

npm install -g @thiagodiogo/psjava

Requires a JDK 11+ with jshell on your PATH. Verify your setup with psjava doctor.

Usage

psjava example.psjava           # run the file
psjava example.psjava --debug   # run, and print the elapsed time at the end
psjava doctor                   # check jshell and the editor syntax highlighting
psjava highlight install        # enable .psjava syntax highlighting in your editors

A .psjava file is just Java:

var name = "world";
print("hello, " + name);

The print helper

psjava defines a print(...) in the session before your code runs (still plain Java — your file stays untouched). It comes with overloads for String, int[], and List:

print("text");                       // text
print(new int[]{1, 2, 3});           // [1, 2, 3]
print(java.util.List.of("a", "b"));  // [a, b]

System.out.println(...) keeps working as usual.

Syntax highlighting

Since a .psjava file is plain Java, psjava highlight install just tells your editor to treat *.psjava as Java — no extension or plugin to maintain:

  • VSCode — adds "*.psjava": "java" to your user settings.json.
  • IntelliJ — maps *.psjava to the Java file type in filetypes.xml.

It detects each editor's config folder automatically (Windows) and asks for the path when it can't find one. Reopen the editor afterwards for the highlighting to kick in. psjava doctor reports, per editor, whether the highlighting is already set up.

How it works

psjava reads your file, prepends the print overloads, and pipes the result straight into jshell -s. The only change made to your source is removing the Windows BOM, which jshell chokes on. That's it — plain Java into JShell.

License

MIT