| |

VerySource

 Forgot password?
 Register
Search
View: 10631|Reply: 87

How to call an unpackaged class under a packaged class

  [Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-9 15:40:01
| Show all posts |Read mode
The manufacturer only provides all compiled class files (no package), and my existing program has packages.

The current situation is that the compiled unpackaged class file can only be called by placing the calling code in the root directory, and it is always not compiled when the code is placed in a class under the package.

How do heroes solve this problem? Thank you.
Reply

Use magic Report

1

Threads

51

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-1-15 21:27:01
| Show all posts
Not in the same directory, of course, you can't call it. The manufacturer does not provide a package, you package it yourself.
After packaging, add it to the CLASSPATH and import it.
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-17 15:45:01
| Show all posts
Pay attention to this problem! !! -_-!
Reply

Use magic Report

0

Threads

10

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 Invalid IP Address

Post time: 2020-1-17 16:45:01
| Show all posts
Add the directory where the class files are located to the CLASSPATH. Such as C: /a/b/c.class
CLASSPATH =% CLASSPATH%; c: / a / b /
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-17 19:27:01
| Show all posts
Add the path of the unpackaged class to the classpath in the environment variable.
Reply

Use magic Report

0

Threads

39

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-1-17 19:36:02
| Show all posts
Type into a .jar file, and then import the .jar file for compilation.
Reply

Use magic Report

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-18 10:18:01
| Show all posts
Classes without packages can cause problems
And problems don't occur often.

I don't think I can ask them to add a package and compile it again.

Or first specify the specific path of these classes at compile time.
Reply

Use magic Report

0

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-1-24 13:36:01
| Show all posts
It seems that classes in the root directory cannot be referenced
May be a Java bug, import does not support root directories


But generally there is no such requirement
Reply

Use magic Report

0

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-1-24 14:00:01
| Show all posts
Seems to be unquotable

java bug

But it ’s not necessary.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-25 12:09:01
| Show all posts
Add the directory where the class files are located to the CLASSPATH.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list