THE FILE FIELD GUIDE
.java

Java Source

Web & Development

JAVA stores source, unlike compiled CLASS files or JAR archives. Inspect it in an editor; running requires the appropriate JDK and dependencies. Source-file launching is not suitable for every project.

What it is used for
Java class and program source
What the file contains
Text
All sections, questions and sources

Content reviewed: · Editor:Kai

Opening steps

Choose your environment or purpose to see its steps.

Inspect source without running

Start with project context.

  1. Open a source copy in an editor.
  2. Inspect package, imports, classes and the entry method.
  3. Look for README, Maven or Gradle configuration.
Build with the required JDK

Apply this to a trusted project.

  1. Identify the required JDK and dependencies.
  2. Open the project root in the IDE rather than only one file.
  3. Follow the build workflow and start with the first compiler error.
Choose the correct launch method

Distinguish source, class and JAR launch modes.

  1. Identify a source-launch example versus a larger application.
  2. Check JDK support, classpath and working directory.
  3. Use the documented entry point and inspect arguments/resources.

Menu labels and support vary by app, OS and version. Preserve the original before making changes.

Troubleshooting by symptom

  • Class-name error: check public class name, filename and package layout.
  • Version mismatch: match source features with the JDK.
  • Missing classes: inspect classpath and dependency/build configuration.
  • Runtime class-version error: compare build JDK and launch runtime.
  • Only the IDE fails: compare its configured JDK with build-tool requirements.
  • Resources missing: inspect working directory, packaged resources and distribution.

JAVA → CLASS / JAR

  1. Compile a trusted project using its documented JDK and build procedure.
  2. Distribute required resources/dependencies and validate startup on the target system.
  3. Package through the project workflow and verify with its required JDK elsewhere.

Renaming does not compile source; packaging alone does not make a runnable JAR.

Compare filenames, packages and layout

Check normal-build class naming and package layout separately from source-launch rules.

Example: a Hello.java tutorial and a Maven project need different launch/build workflows.

Source for these steps:Oracle · The java Command / Oracle · The jar Command

What to retain for migration

Retain JDK requirements, dependencies, resources and arguments; ask for source when only build outputs remain.

Source for these steps:Oracle · The java Command / Oracle · The jar Command

Related-format differences

Related-format differences
Format / methodRoleWhat to verify
JAVASourceJDK/dependencies
CLASSCompiled classCompatible runtime
JARClass/resource archiveEntry point/dependencies

Handling and security

Building and running execute code; review unfamiliar build scripts as well as source.

Questions and answers

Should I open it like an application?

Inspect with an editor; run through the development workflow.

Is any JDK sufficient?

Version, libraries and configuration must match.

Can I rename JAVA to JAR?

That neither compiles nor packages it.

Does compilation eliminate library dependencies?

Runtime libraries can still be required; inspect packaging and launch classpath.

Must I open each JAVA separately?

An IDE project view helps trace references; keep the original layout.

Format facts: name, steward and MIME type
Formal name
Java source code
Steward / specification
Java platform / code author
MIME type
Depends on the producer or server; an extension alone does not establish a MIME type.

Primary and official sources

  • Official documentationThe java Command

    Official Java launcher reference.

    Oracle · Link checked:
  • Official documentationThe jar Command

    Documents JAR listing, extraction and structure.

    Oracle · Link checked: